StEEmcPool/muEztPanitkin/EEdsmAna.cxx

00001 //#include <iostream> 00002 00003 #include <TObjArray.h> 00004 #include <TH2.h> 00005 #include <TFile.h> 00006 00007 #include <StMessMgr.h> 00008 00009 #include "EEdsmAna.h" 00010 00011 #define EEmapTP_USE // trick instattiates data only in the cxx 00012 #include "StEEmcUtil/EEdsm/EEmapTP.h" 00013 #undef EEmapTP_USE 00014 00015 #include "StEEmcUtil/EEdsm/EEdsm0.h" 00016 #include "StEEmcUtil/EEdsm/EEdsm1.h" 00017 #include "StEEmcUtil/EEdsm/EEdsm2.h" 00018 #include "StEEmcUtil/EEdsm/EEdsm3.h" 00019 00020 00021 ClassImp(EEdsmAna) 00022 00023 //-------------------------------------------------- 00024 EEdsmAna::EEdsmAna(const Char_t *name, int year) 00025 : myName(name) 00026 , mYear(year) 00027 { 00028 nTot=0; 00029 00030 mJPthr[0]=16; 00031 mJPthr[1]=24; 00032 mJPthr[2]=30; 00033 mJPthr[3]=40; 00034 int TPthrSelc = 2; 00035 int HTTPthrSelc = 2; 00036 00037 //===================== DSM 0 =============== 00038 Nee0 = 9; 00039 ee0 = new EEdsm0[Nee0]; 00040 Nee0out = 12; 00041 ee0outTPadc = new int [Nee0out]; 00042 ee0outHTadc = new int [Nee0out]; 00043 00044 // set pedestals initially to 0 00045 ped0 = new int *[Nee0]; // WARN, may be old from 2005 ???, probably not used in the code 00046 for (int ibr = 0;ibr < Nee0; ibr++) { 00047 ped0[ibr] = new int [ee0[ibr].getNc()]; 00048 for(int ch = 0;ch < ee0[ibr].getNc();ch++) 00049 ped0[ibr][ch]=0; 00050 } 00051 00052 //===================== DSM 1 =============== 00053 Nee1 = 2; 00054 ee1 = new EEdsm1[Nee1]; 00055 for(int i = 0;i < Nee1;i++) ee1[i].setYear(mYear, mJPthr, TPthrSelc, HTTPthrSelc); 00056 ee1[0].setType(1); 00057 ee1[1].setType(2); 00058 ee1out3JPadc = new int [Nee1]; 00059 00060 //===================== DSM 2 =============== 00061 ee2 = new EEdsm2; // Endcap 00062 ee2->setYear(mYear); 00063 00064 be2 = new EEdsm2[Nbe2]; 00065 for(int i = 0;i < Nbe2;i++) // Barrel 00066 be2[i].setYear(mYear); 00067 00068 //===================== DSM 3 =============== 00069 ee3 = new EEdsm3; 00070 ee3->setYear(mYear); 00071 00072 clear(); 00073 } 00074 00075 //-------------------------------------------------- 00076 EEdsmAna::~EEdsmAna() { 00077 } 00078 00079 //-------------------------------------------------- 00080 void EEdsmAna::clear() { 00081 00082 for (int i=0;i<Nee0;i++) if (ee0) ee0[i].clear(); 00083 for (int i=0;i<Nee0out;i++) { //# boards != # outputs 00084 if (ee0outTPadc) ee0outTPadc[i]=0; 00085 if (ee0outHTadc) ee0outHTadc[i]=0; 00086 } 00087 00088 for (int i=0;i<Nee1;i++) { // # boards ==# outputs 00089 if (ee1) ee1[i].clear(); 00090 if (ee1out3JPadc) ee1out3JPadc[i]=0; 00091 } 00092 00093 memset(ee1outTPthrMax, 0, sizeof(ee1outTPthrMax)); 00094 memset(ee1outHTTPthrMax, 0, sizeof(ee1outHTTPthrMax)); 00095 00096 for (int i=0;i<EEnJetPatch;i++) { 00097 ee1outJPadc[i]=0; 00098 ee1outHT[i]=0; 00099 AdjJPsum[i]=0; 00100 } 00101 00102 for (int i = 0;i < EEnHalf;i++) { 00103 ee1outTPthrMax[i] = 0; 00104 ee1outHTTPthrMax[i] = 0; 00105 } 00106 00107 if (ee2) ee2->clear(); 00108 ee2outHT=0; 00109 00110 for (int i=0;i<Nbe2;i++) 00111 if (be2) be2[i].clear(); 00112 00113 if (ee3) ee3->clear(); 00114 } 00115 00116 //-------------------------------------------------- 00117 void EEdsmAna::initHisto(TObjArray *HList){ 00118 // .................level-0 input, 2D, HT .............. 00119 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00120 H0inHT[iJ] = new TH2F(Form("dsm0inJP%d_HT", iJ + 1), 00121 Form("HT input, DSM layer-0, Jet Patch %d (Steve), trig=%s;input 0-DSM ADC value;Trig Patch ID", iJ + 1, myName), 00122 64, -0.5, 63.5, EEnTPinJP, 0.5, EEnTPinJP + 0.5); 00123 if (HList) HList->Add(H0inHT[iJ]); 00124 } 00125 00126 H0inHTall = new TH2F("dsm0inJPall_HT", 00127 Form("HT input, DSM layer-0, all trig Patches, trig=%s; Hanks ID=10*brd+inpID", myName), 00128 90, -0.5, 89.5, 64, -0.5, 63.5); 00129 if (HList) HList->Add(H0inHTall); 00130 00131 // ........level-0 input, 2D, TP sum 00132 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00133 H0inTP[iJ] = new TH2F(Form("dsm0inJP%d_TP", iJ + 1), 00134 Form("TP input, DSM layer-0, Jet Patch %d (Steve), trig=%s;input to level 0;Trig Patch ID", iJ + 1,myName), 00135 64, -0.5, 63.5, EEnTPinJP, 0.5, EEnTPinJP + 0.5); 00136 if (HList) HList->Add(H0inTP[iJ]); 00137 } 00138 00139 H0inTPall = new TH2F("dsm0inJPall_TP", Form("TP input, DSM layer-0, all trig Patches, trig=%s", myName), 00140 90, -0.5, 89.5, 64, -0.5, 63.5); 00141 if (HList) HList->Add( H0inTPall); 00142 00143 // .................level-1 input, 2D 00144 //================================ TP 00145 00146 for(int iJ = 0;iJ < EEnHalfJetPatch;iJ++) { 00147 H1inTPvEmu[iJ] = new TH2F(Form("dsm1HJP%d_TP", iJ + 1), 00148 Form("TP input vs. emulated, DSM layer-1, brd=%d ch=%d, trig=%s;emulated TP from level-0;input to level-1", iJ/6, iJ%6, myName), 00149 40, 0., 400, 40, 0, 400); 00150 if (HList) HList->Add(H1inTPvEmu[iJ]); 00151 } 00152 00153 //================================ HT 00154 for(int iJ = 0;iJ < EEnHalfJetPatch;iJ++) { 00155 H1inHTvEmu[iJ] = new TH2F(Form("dsm1HJP%d_HT", iJ + 1), 00156 Form("HT input vs.emu, DSM-1, Half Patch %d (Falk), trig=%s;emulated HT from level-0;input to level-1", iJ + 1, myName), 00157 64, -0.5, 63.5, 4, -0.5, 3.5); 00158 if (HList) HList->Add(H1inHTvEmu[iJ]); 00159 } 00160 00161 // .................level-2 input 00162 00163 //================================ HT 00164 for(int iJ = 0;iJ < EEnHalf;iJ++) { 00165 H2inHTTP[iJ] = new TH2F(Form("dsm2Half%d_HTTP", iJ + 1), 00166 Form("TP (+) HTTP thres, JP_Falk(%d+%d+%d), trig=%s;emu layer1 out: maxTPthr*4 + maxHTTPthr;layer2 inp: TPthr*2 + HTTP", 00167 3*iJ, (3*iJ) + 1, (3*iJ) + 2, myName), 00168 16, -0.5, 15.5, 4, -0.5, 3.5); 00169 if (HList) HList->Add(H2inHTTP[iJ]); 00170 } 00171 00172 //================================ half Etot sum 00173 for(int iJ = 0;iJ < EEnHalf;iJ++) { 00174 H1inEtot[iJ] = new TH1F(Form("dsm2Half%d_Etot", iJ + 1), 00175 Form("Etot for JP_Falk(%d+%d+%d), trig=%s; level2 input", 3*iJ, (3*iJ) + 1, (3*iJ) + 2, myName), 00176 32, -0.5, 31.5); 00177 if (HList) HList->Add(H1inEtot[iJ]); 00178 } 00179 00180 // Total energy histos 00181 for(int iJ = 0;iJ < mxEtotBit;iJ++) { 00182 HEetot[iJ] = new TH1F(Form("dsm2E_etot%d", iJ), 00183 Form("EEMC ETOT BIT=%d, trig=%s; EEMC ETOT emul sum over 1 brd @ level2", iJ, myName), 00184 48, 15.5, 63.5); 00185 HEetot[iJ]->SetLineColor((iJ == 1) ? kRed : kBlue); 00186 if (HList) HList->Add(HEetot[iJ]); 00187 00188 HBetot[iJ] = new TH1F(Form("dsm2B_etot%d", iJ), 00189 Form("BEMC ETOT BIT=%d, trig=%s; BEMC ETOT emul sum over 3 brds @ level2", iJ, myName), 00190 190, 65.5, 255.5); 00191 HBetot[iJ]->SetLineColor((iJ == 1) ? kRed : kBlue); 00192 if (HList) HList->Add(HBetot[iJ]); 00193 00194 HBEetot[iJ] = new TH1F(Form("dsm2BE_etot%d", iJ), 00195 Form("B+EEMC ETOT BIT=%d, trig=%s; B+EEMC ETOT emul sum over 4 brds @ level2", iJ, myName), 00196 190, 65.5, 255.5); 00197 HBEetot[iJ]->SetLineColor((iJ == 1) ? kRed : kBlue); 00198 if (HList) HList->Add(HBEetot[iJ]); 00199 } 00200 00201 // .................level-3 input 00202 //================================ HT 00203 H3inHTTP = new TH2F("dsm3_HTTP", Form("HTTP layer=3, trig=%s;emu layer2 out: orTPbit*2 + orHTTPbit;layer3 inp: TPbit*2 + HTTPbit", myName), 00204 4, -0.5, 3.5, 4, -0.5, 3.5); 00205 if (HList) HList->Add(H3inHTTP); 00206 00207 //..................Jet Patch sums 00208 //=================================summed patch spectra 00209 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00210 int steve_jp = ((iJ + 2) % EEnJetPatch) + 1; //stored by dsm input number 0-5 Want by Steves jp # 00211 H4jpSums[iJ] = new TH1F(Form("JP%d_sum", steve_jp), 00212 Form("Emulated Sum Jet Patch %d (DSMin %d);Jet Patch Emu Sum;Freq", ((iJ + 2) % EEnJetPatch) + 1, iJ), 00213 300, -0.5, 299.5); 00214 if (HList) HList->Add(H4jpSums[iJ]); 00215 } 00216 00217 //=================================Jet patch over threshold 00218 for (int iJ = 0;iJ < EEnThresh;iJ++) { 00219 TH1F *h = new TH1F(Form("JPsumTh%d", iJ), 00220 (iJ == 0) ? Form("Emu Jet Patch sum > %d", mJPthr[0]) : 00221 (((iJ == 1) || (iJ == 2)) ? Form("Emu Jet Patch sum in [%d,%d]", mJPthr[iJ], mJPthr[iJ + 1] - 1) : 00222 Form("Emu Jet Patch sum > %d", mJPthr[iJ])), 00223 6, 0.5, 6.5); 00224 h->GetXaxis()->SetTitle("Steve's Jet Patch ID"); 00225 h->GetYaxis()->SetTitle("Freq"); 00226 h->SetFillColor(kBlue); 00227 H4jpFreq[iJ]=h; 00228 if (HList) HList->Add(h); 00229 } 00230 00231 //=================================summed adjacent patch spectra 00232 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00233 int steve_jp = ((iJ + 2) % EEnJetPatch) + 1; //stored by dsm input number 0-5 Want by Steves jp # 00234 int steve_jp2 = ((iJ + 3) % EEnJetPatch) + 1; 00235 H4adjpSums[iJ] = new TH1F(Form("JP%d%d_sum", steve_jp, steve_jp2), 00236 Form("Emulated Sum Jet Patches %d+%d;Jet Patch Emu Sum;Freq", steve_jp, steve_jp2), 00237 150, -0.5, 149.5); 00238 if (HList) HList->Add(H4adjpSums[iJ]); 00239 } 00240 00241 //=================================adjacent patch correlation 00242 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00243 int steve_jp = ((iJ + 2) % EEnJetPatch) + 1; //stored by dsm input number 0-5 Want by Steves jp # 00244 int steve_jp2 = ((iJ + 3) % EEnJetPatch) + 1; 00245 H4adjPcor[iJ] = new TH2F(Form("JP%d%d_cor", steve_jp, steve_jp2), 00246 Form("Emulated Sum Jet Patches %d vs %d;Jet Patch %d Sum;Jet Patch %d Sum", steve_jp, steve_jp2, steve_jp, steve_jp2), 00247 60, 9.5, 69.5, 60, 9.5,69.5); 00248 if (HList) HList->Add(H4adjPcor[iJ]); 00249 } 00250 00251 { //====================freq summed adjacent patch spectra over thresh 00252 H4adjpFreq = new TH1F("JPadjTh", "Adjacent Jet patches both over thr0;DSM Adjacent Jet Patch Emu Sum (FEE crate add 2);Freq", 00253 8, -0.5, 7.5); 00254 if (HList) HList->Add(H4adjpFreq); 00255 } 00256 00257 { 00258 // added in 2005 00259 H5jpPed = new TH2F("JPpedZoom", "Zoom in of 1x1 JP pedestals;Steve's JP ID", 00260 EEnJetPatch, 0.5, EEnJetPatch + 0.5, 41, 4.5, 45.5); //2005: Y:40,34.5,74.5 00261 if (HList) HList->Add(H5jpPed); 00262 } 00263 00264 { 00265 H5jpFreq = new TH1F("JPtotFreq", Form("JP DSM sum > %d;Steve's JP ID", mJPthr[1]), 00266 EEnJetPatch, 0.5, EEnJetPatch + 0.5); 00267 H5jpFreq->SetFillColor(kGreen); 00268 if (HList) HList->Add(H5jpFreq); 00269 00270 H5jpHot = new TH1F("JPpedHot", "Hot towers;Steve's JP ID", 00271 EEnJetPatch, 0.5, EEnJetPatch + 0.5); 00272 H5jpHot->SetFillColor(kRed); // this histo is updated in presenter - a bit tricky 00273 if (HList) HList->Add(H5jpHot); // is _not_ filled by sorter 00274 } 00275 } 00276 00277 //-------------------------------------------------- 00278 void EEdsmAna::resetHisto(){ 00279 // .................level-0 input, 2D, HT .............. 00280 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00281 if (H0inHT[iJ]) H0inHT[iJ]->Reset(); 00282 } 00283 if (H0inHTall) H0inHTall->Reset(); 00284 // ........level-0 input, 2D, TP sum 00285 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00286 if (H0inTP[iJ]) H0inTP[iJ]->Reset(); 00287 } 00288 if (H0inTPall) H0inTPall->Reset(); 00289 00290 // .................level-1 input, 2D 00291 //================================ TP 00292 for(int iJ = 0;iJ < EEnHalfJetPatch;iJ++) { 00293 if (H1inTPvEmu[iJ]) H1inTPvEmu[iJ]->Reset(); 00294 } 00295 //================================ HT 00296 for(int iJ = 0;iJ < EEnHalfJetPatch;iJ++) { 00297 if (H1inHTvEmu[iJ]) H1inHTvEmu[iJ]->Reset(); 00298 } 00299 00300 // .................level-2 input 00301 //================================ HT 00302 for(int iJ = 0;iJ < EEnHalf;iJ++) { 00303 if (H2inHTTP[iJ]) H2inHTTP[iJ]->Reset(); 00304 } 00305 //================================ half Etot sum 00306 for(int iJ = 0;iJ < EEnHalf;iJ++) { 00307 if (H1inEtot[iJ]) H1inEtot[iJ]->Reset(); 00308 } 00309 00310 // Total energy histos 00311 for(int iJ = 0;iJ < mxEtotBit;iJ++) { 00312 if (HEetot[iJ]) HEetot[iJ]->Reset(); 00313 if (HBetot[iJ]) HBetot[iJ]->Reset(); 00314 if (HBEetot[iJ]) HBEetot[iJ]->Reset(); 00315 } 00316 00317 // .................level-3 input 00318 //================================ HT 00319 if (H3inHTTP) H3inHTTP->Reset(); 00320 00321 //..................Jet Patch sums 00322 //=================================summed patch spectra 00323 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00324 if (H4jpSums[iJ]) H4jpSums[iJ]->Reset(); 00325 } 00326 //=================================Jet patch over threshold 00327 for (int iJ = 0;iJ < EEnThresh;iJ++) { 00328 if (H4jpFreq[iJ]) H4jpFreq[iJ]->Reset(); 00329 } 00330 //=================================summed adjacent patch spectra 00331 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00332 if (H4adjpSums[iJ]) H4adjpSums[iJ]->Reset(); 00333 } 00334 //=================================adjacent patch correlation 00335 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00336 if (H4adjPcor[iJ]) H4adjPcor[iJ]->Reset(); 00337 } 00338 { //====================freq summed adjacent patch spectra over thresh 00339 if (H4adjpFreq) H4adjpFreq->Reset(); 00340 } 00341 { 00342 // added in 2005 00343 if (H5jpPed) H5jpPed->Reset(); 00344 } 00345 { 00346 if (H5jpFreq) H5jpFreq->Reset(); 00347 if (H5jpHot) H5jpHot->Reset(); 00348 } 00349 } 00350 00351 00352 //-------------------------------------------------- 00353 void EEdsmAna::sort( const unsigned char * dsm0inp, 00354 const unsigned short int * dsm1inp, 00355 const unsigned short int * dsm2inp, 00356 const unsigned short int * dsm3inp) { 00357 nTot++; 00358 00359 if (dsm0inp) readDsm0(dsm0inp); 00360 if (dsm1inp) readDsm1(dsm1inp); 00361 if(dsm2inp) readDsm2(dsm2inp); 00362 if(dsm3inp) readDsm3(dsm3inp); 00363 00364 emulDsm0(); 00365 emulDsm1(); 00366 emulDsm2(); 00367 00368 histoDsm0(); 00369 histoDsm1(); 00370 histoDsm2(); 00371 histoDsm3(); 00372 00373 return; 00374 00375 LOG_DEBUG << "==================================" << endm; 00376 printAllEndcap(); 00377 printAllBarrel(); 00378 00379 #if 0 00380 // test for Steve: 00381 int iJ; 00382 for(iJ=0;iJ<EEnHalf;iJ++) { 00383 if(ee1outTPthrMax[iJ]>=ee1outHTTPthrMax[iJ]) continue; 00384 LOG_DEBUG << Form("NEW_EVE==================================\n ee1outTPthrMax[%d]=%d <ee1outHTTPthrMax[%d]=%d\n",iJ,ee1outTPthrMax[iJ],iJ,ee1outHTTPthrMax[iJ]) << endm; 00385 goto dump; 00386 } 00387 #endif 00388 00389 } 00390 00391 00392 //-------------------------------------------------- 00393 void EEdsmAna::emulDsm0() { 00394 if (ee0) { 00395 for (int i = 0;i < EEnTPphi;i++) { 00396 for(int j = 0;j < EEnTPeta;j++) { 00397 const EEmapTP &y = eeMapTP[i][j]; 00398 //if (y) { 00399 int ibr = y.brdIn - 1; 00400 int ch = y.chIn; 00401 int chOut = y.chOut; 00402 const EEdsm0 &br = ee0[ibr]; 00403 // ........ TP .......... 00404 ee0outTPadc[chOut] += br.getInpTP6bit(ch); 00405 //.......... HT .............. 00406 int val= br.getInpHT6bit(ch); 00407 if(ee0outHTadc[chOut]< val)ee0outHTadc[chOut]=val; 00408 //} 00409 } 00410 } 00411 } 00412 } 00413 00414 //-------------------------------------------------- 00415 void EEdsmAna::emulDsm1() { 00416 if (ee1) { 00417 for (int i=0;i<Nee1;i++) { 00418 const EEdsm1 &br = ee1[i]; //Select data for board 1 or 2 00419 int maxTPthr=0; 00420 int maxHTTPthr=0; 00421 for(int j=0;j<br.getNc(); j++) { 00422 int ix=j+i*br.getNc(); 00423 int ijp=ix/2; 00424 ee1outJPadc[ijp]+=br.getInpTPsum(j); 00425 // Note jet patches are numbered in DSM input order. So ijp=0 is FEE crate 3. 00426 ee1out3JPadc[i]+=br.getInpTPsum(j); 00427 //int val= br.getHTthr(j); 00428 //if(ee1outHT[ijp]< val)ee1outHT[ijp]=val; 00429 //if(maxTPthr< br.getTPthr(j)) maxTPthr= br.getTPthr(j); 00430 //if(maxHTTPthr< br.getHTTPthr(j)) maxHTTPthr= br.getHTTPthr(j); 00431 } 00432 ee1outTPthrMax[i] =maxTPthr; 00433 ee1outHTTPthrMax[i]=maxHTTPthr; 00434 } 00435 } 00436 //Add some further processing to check jet patch sums for passing thresholds 00437 //and form adjacent patch sums. 00438 for (int i=0;i<EEnJetPatch;i++) { 00439 AdjJPsum[i]=ee1outJPadc[i]+ee1outJPadc[(i+1)%EEnJetPatch]; //sum adj patches 00440 } 00441 } 00442 00443 //-------------------------------------------------- 00444 void EEdsmAna::emulDsm2() { 00445 if (ee2) { 00446 ee2outHT=ee2->get3JPHTthr(0); 00447 if(ee2outHT<ee2->get3JPHTthr(1))ee2outHT=ee2->get3JPHTthr(1); 00448 } 00449 } 00450 00451 //-------------------------------------------------- 00452 void EEdsmAna::readDsm0(const unsigned char *EEMC) { 00453 /*Gets level 0 DSM inputs and reorders them. They 00454 are stored 7 -> 0 followed by 15 -> 8. Output is 00455 ordered as physically input to boards, 0 -> 15. 00456 */ 00457 if (EEMC && ee0) { 00458 //--------------------- initialize input to DSM level-0 00459 for(int ibr = 0;ibr < Nee0;ibr++) { // index, boards ID= ibr+1 00460 int k = 16 * ibr; // begin of data for given board 00461 // fill in lower 8 words [ 0,1...,7] 00462 for(int i = 0;i < 8;i++) ee0[ibr].setBite(7 - i, EEMC[k + i]); 00463 // fill in higher 8 words [8,9,....,15] 00464 for(int i = 8;i < 16;i++) ee0[ibr].setBite(23 - i, EEMC[k + i]); 00465 ee0[ibr].unpack(); 00466 } 00467 } 00468 } 00469 00470 //-------------------------------------------------- 00471 void EEdsmAna::readDsm1(const unsigned short *EEMC_l1) { 00472 /* Gets level 1 DSM inputs (output of level 0) and 00473 reorders them. They are stored 3 ->0 followed by 00474 7 -> 4 followed by 11 -> 8 and 15 -> 12. Only 0-5 00475 and 8-13 are used, the first group for the first 00476 board. Output is ordered as physically input to 00477 the board. For first board the order is crate 3, 00478 4 then 5, and for second board crate 6, 1 then 2. 00479 */ 00480 if (EEMC_l1 && ee1) { 00481 for(int i = 0;i < Nee1;i++) { 00482 ee1[i].setWord(0, EEMC_l1[3 + i*8]); 00483 ee1[i].setWord(1, EEMC_l1[2 + i*8]); 00484 ee1[i].setWord(2, EEMC_l1[1 + i*8]); 00485 ee1[i].setWord(3, EEMC_l1[0 + i*8]); 00486 ee1[i].setWord(4, EEMC_l1[7 + i*8]); 00487 ee1[i].setWord(5, EEMC_l1[6 + i*8]); 00488 } 00489 } 00490 } 00491 00492 //-------------------------------------------------- 00493 void EEdsmAna::readDsm2(const unsigned short *EMC) { 00494 if (EMC && ee2 && be2) { 00495 //Endcap 00496 ee2->setWord(0, EMC[5]); 00497 ee2->setWord(1, EMC[4]); 00498 //Barrel 00499 be2[0].setWord(0, EMC[3]); 00500 be2[0].setWord(1, EMC[2]); 00501 be2[1].setWord(0, EMC[1]); 00502 be2[1].setWord(1, EMC[0]); 00503 be2[2].setWord(0, EMC[7]); 00504 be2[2].setWord(1, EMC[6]); 00505 } 00506 } 00507 00508 //-------------------------------------------------- 00509 void EEdsmAna::readDsm3( const unsigned short *lastDSM) { 00510 if (lastDSM && ee3) { 00511 ee3->setWord(0, lastDSM[0]); 00512 } 00513 } 00514 00515 //-------------------------------------------------- 00516 void EEdsmAna::histoDsm0() { 00517 if (ee0) { 00518 for(int i = 0;i < EEnTPphi;i++) { 00519 for(int j = 0;j < EEnTPeta;j++) { 00520 const EEmapTP &y = eeMapTP[i][j]; 00521 //if (y) { 00522 int ibr = y.brdIn - 1; 00523 int ch = y.chIn; 00524 int iJP = y.JPid - 1; 00525 if ((iJP >= 0) && (iJP < EEnJetPatch)) { 00526 H0inHT[iJP]->Fill(ee0[ibr].getInpHT6bit(ch), y.TPid); 00527 H0inTP[iJP]->Fill(ee0[ibr].getInpTP6bit(ch), y.TPid); 00528 H0inHTall->Fill((10 * ibr) + ch, ee0[ibr].getInpHT6bit(ch)); 00529 H0inTPall->Fill((10 * ibr) + ch, ee0[ibr].getInpTP6bit(ch)); 00530 } 00531 //} 00532 } 00533 } 00534 } 00535 } 00536 00537 //-------------------------------------------------- 00538 void EEdsmAna::histoDsm1(){ 00539 if (ee1) { 00540 for (int i = 0;i < Nee1;i++) { 00541 const EEdsm1 &br = ee1[i]; 00542 //if (br) { 00543 for(int j = 0;j < br.getNc();j++) { 00544 int ix = j + (i * br.getNc()); 00545 // .... TP .................. 00546 H1inTPvEmu[ix]->Fill(ee0outTPadc[ix], br.getInpTPsum(j)); 00547 //..... HT ............ 00548 //H1inHTvEmu[ix]->Fill(ee0outHTadc[ix], br.getHTthr(j)); 00549 } 00550 //} 00551 } 00552 } 00553 00554 /* 2006 00555 6) For the upper 4 plots ( H4jpFreq[i]), change the JP sum cuts to: 00556 JP sum > 16 00557 JP sum in range [24,29] 00558 JP sum in range [30,39] 00559 JP sum > 40 00560 */ 00561 00562 for (int i = 0;i < EEnJetPatch;i++) { //histos for jet patch sums 00563 int steve_jp = ((i + 2) % EEnJetPatch) + 1; //stored by dsm input number 0-5 Want by Steves jp # 00564 H4jpSums[i]->Fill(ee1outJPadc[i]); 00565 int JPene = ee1outJPadc[i]; 00566 if(JPene > mJPthr[0]) H4jpFreq[0]->Fill(steve_jp); 00567 if(JPene > mJPthr[3]) H4jpFreq[3]->Fill(steve_jp); 00568 else if(JPene > mJPthr[2]) H4jpFreq[2]->Fill(steve_jp); 00569 else if(JPene > mJPthr[1]) H4jpFreq[1]->Fill(steve_jp); 00570 00571 H5jpPed->Fill(steve_jp, ee1outJPadc[i]); 00572 if (ee1outJPadc[i] > mJPthr[1]) H5jpFreq->Fill(steve_jp); 00573 int j = (i + 1) % EEnJetPatch; 00574 H4adjPcor[i]->Fill(ee1outJPadc[i], ee1outJPadc[j]); 00575 H4adjpSums[i]->Fill(AdjJPsum[i]); 00576 00577 if ((ee1outJPadc[i] > mJPthr[1]) && (ee1outJPadc[(i + 1) % EEnJetPatch] > mJPthr[1])) H4adjpFreq->Fill(steve_jp); 00578 } 00579 } 00580 00581 //-------------------------------------------------- 00582 void EEdsmAna::histoDsm2() { 00583 if (ee2) { 00584 //------------ HT --------------- 00585 /*for (int iJ = 0;iJ < EEnHalf;iJ++) { 00586 int max = 0; 00587 for(int i = 3 * iJ;i < ((3 * iJ) + 3);i++) { 00588 if (max < ee1outHT[i]) max = ee1outHT[i]; 00589 } 00590 }*/ 00591 00592 //------------ TP & HTTP since 2006 --------------- 00593 /* 00594 4) The upper 2 plots need to be completely redefined. The result will be interpretable by me 00595 and probably by few others until I train them, but it's not easy to do better unless we have 00596 access to the register values that tell DSM exactly which thresholds we are choosing from TP 00597 and HT x TP bits. We want to change both histograms to be 16 channels in x by 4 channels in y. 00598 The left-hand plot should still deal with the layer 1 DSM that Falk labels for JP 00599 0+1+2, and the right-hand plot for JP3+4+5. 00600 00601 To form the 4-bit word for x in each of the above histograms, do the following: 00602 a) loop over the 6 inputs to the layer 1 DSM and extract bits 12-13; place the highest of 00603 these 6 2-bit values into the upper 2 bits of the address for x. 00604 b) repeat (a), but now for bits 14-15 of the 6 inputs; place the highest of these 6 2-bit 00605 values into the lower 2 bits of the 4-bit address for x. 00606 x thus measures: (TP bits for highest threshold passed)*4 + (HTxTP bits for highest threshold 00607 passed) 00608 00609 For the y-value in these histograms, form a 2-bit word with bit 1=bit 9 of the corresponding 00610 layer 2 DSM input word bit 0=bit 7 of the corresponding layer 2 DSM input word (all bits 00611 numbered starting from 0). 00612 y thus measures: (selected TP threshold passed?Y or N)*2 00613 +(selected HT x TP threshold passed?Y or N) 00614 00615 */ 00616 00617 for(int iJ = 0;iJ < EEnHalf;iJ++) { 00618 int x = (ee1outTPthrMax[iJ] * 4) + ee1outHTTPthrMax[iJ]; 00619 int y = (ee2->getTPthr(iJ) * 2) + ee2->getHTTPthr(iJ); 00620 H2inHTTP[iJ]->Fill(x,y); 00621 } 00622 00623 /* in 2006+ 00624 2 1D plots, one for each layer 1 DSM (i.e., Falk JP0+1+2 and Falk JP3+4+5). 00625 The x-axis should be 32 channels and represent the value extracted from bits 0-4 of 00626 the corresponding EEMC input to the layer 2 DSM. The plots should be labeled: 00627 ETOT FOR JP0+1+2 and ETOT FOR JP3+4+5. 00628 */ 00629 00630 for (int iJ = 0;iJ < EEnHalf;iJ++) H1inEtot[iJ]->Fill(ee2->get3JPsum(iJ)); 00631 } 00632 00633 if (ee3) { 00634 //Total energy histos 00635 /* 00636 64 channels x by 2 channels y : 00637 x-axis (label EEMC ETOT emulated) ; value = sum over 00638 2 EEMC inputs to layer 2 DSM the values in bits 0-4 for each input. 00639 00640 y-axis (label EEMC ETOT BIT): value = bit 11 of layer 00641 2 DSM output (or of TCU input). 00642 */ 00643 unsigned short sumE = ee2->get3JPsum(0) + ee2->get3JPsum(1); 00644 HEetot[ee3->getEndcapEsumthr1bit()]->Fill(sumE); 00645 00646 //BARREL histos 2006 00647 /* 00648 256 channels x by 2 channels y: 00649 x-axis (label BEMC ETOT emulated) ; value = sum over 00650 6 BEMC inputs to layer 2 DSM the values in bits 0-4 for each input. 00651 00652 y-axis (label BEMC ETOT BIT): value = bit 4 of layer 00653 2 DSM output (or of TCU input). 00654 */ 00655 unsigned short sumB = 0; 00656 for(int i = 0;i < Nbe2;i++) { 00657 sumB += be2[i].get3JPsum(0); 00658 sumB += be2[i].get3JPsum(1); 00659 } 00660 HBetot[ee3->getBarreEsumThr1bit()]->Fill(sumB); 00661 00662 /* 00663 256 channels x by 2 channels y: 00664 x-axis (label B+EEMC ETOT emulated) ; value = sum over 00665 6 BEMC+2 EEMC inputs to layer 2 DSM the values in bits 0-4 for each input. 00666 00667 y-axis (label B+EEMC ETOT BIT): value = bit 15 of layer 00668 2 DSM output (or of TCU input). 00669 */ 00670 00671 HBEetot[ee3->getEtotThr1bit()]->Fill(sumB + sumE); 00672 } 00673 } 00674 00675 //-------------------------------------------------- 00676 void EEdsmAna::histoDsm3() { 00677 if (ee3) { 00678 /* 00679 The plot should be replaced with a 4 x 4 histo: 00680 x-axis = 2-bit word constructed from: 00681 bit 0=OR of bit 7 on two EEMC inputs to layer 2 DSM bit 1=OR of bit 9 on two EEMC inputs to layer 2 DSM y-axis = 2-bit word constructed from: 00682 bit 0=bit 12 of layer 2 DSM output (or TCU input) bit 1=bit 14 of layer 2 DSM output (or TCU input) 00683 00684 This histogram should have the "normal" appearance of a diagonal band; the x-axis is the emulated TP and HT x TP inputs to layer 2, and the y-axis is the actual output from layer 2. 00685 00686 */ 00687 bool x_b0 = ee1outTPthrMax[0] || ee1outTPthrMax[1]; 00688 bool x_b1 = ee1outHTTPthrMax[0] || ee1outHTTPthrMax[1]; 00689 int x = (x_b1 * 2) + x_b0; 00690 int y = (ee3->getEndcapHTTPthr1bit() * 2) +ee3->getEndcapTPthr1bit(); 00691 H3inHTTP->Fill(x, y); 00692 } 00693 } 00694 00695 //-------------------------------------------------- 00696 void EEdsmAna::printDsm0map() const { 00697 printf("TP Map level-0 \n "); 00698 for(int j=0;j< EEnTPeta;j++) 00699 printf(" iEta=%d ",j); 00700 printf("\n "); 00701 for(int j=0;j< EEnTPeta;j++) 00702 printf("JP/TP brd:ch->outCh "); 00703 for(int i=0;i<EEnTPphi; i++) { 00704 int phi=111-i*12; 00705 if(phi<0) phi+=360; 00706 printf("\nPhi/deg=%3d ",phi); 00707 for(int j=0;j< EEnTPeta;j++) { 00708 EEmapTP *y=&eeMapTP[i][j]; 00709 printf("%d/%2d %2d:%2d -> %2d ",y->JPid,y->TPid,y->brdIn,y->chIn,y->chOut); 00710 } 00711 } 00712 printf("\n"); 00713 } 00714 00715 //-------------------------------------------------- 00716 void EEdsmAna::printAllEndcap(int k) const { 00717 printf("\n\nEEdsmAna(%s)::print(eve=%d) , year=%d \n",myName,nTot,mYear); 00718 for(int i=0;i<Nee0;i++) { 00719 printf("\n----------- level-0 Board %2d ",i+1); 00720 ee0[i].print(); 00721 } 00722 printf("\n----------- level-0 emulated output \n ch ="); 00723 for(int i=Nee0out-1;i>=0; i--) printf(" %4d ",i); 00724 printf("\n TP ="); 00725 for(int i=Nee0out-1;i>=0; i--) printf(" %4d ",ee0outTPadc[i]); 00726 printf("\nHTadc ="); 00727 for(int i=Nee0out-1;i>=0; i--) printf(" %4d ",ee0outHTadc[i]); 00728 printf("\n\n----------- level-1 -----------------\n "); 00729 for(int i=0;i<Nee1;i++) { 00730 printf("\n----------- level-1 Board %2d , ",i+1); 00731 ee1[i].print(); 00732 printf("emul out 3x.9 JP_Falk(%d+%d+%d) energy/dec: 13bit=%d 8bit=%d mxTPthr=%d mxHTTPthr=%d\n",3*i,3*i+1,3*i+2,ee1out3JPadc[i],ee1out3JPadc[i]>>5, ee1outTPthrMax[i], ee1outHTTPthrMax[i]); 00733 } 00734 printf("\n----------- level-1 emulated output \n JP_Falk ="); 00735 int Njp=EEnJetPatch; 00736 for(int i=Njp-1;i>=0; i--) printf(" %4d ",i); 00737 printf("\n JP_Steve="); 00738 for(int i=Njp-1;i>=0; i--) printf(" %4d ",(i+2)%6+1); 00739 printf("\n JPsum ="); 00740 for(int i=Njp-1;i>=0; i--) printf(" %4d ",ee1outJPadc[i]); 00741 printf("\n HTthr ="); 00742 for(int i=Njp-1;i>=0; i--) printf(" %4d ",ee1outHT[i]); 00743 if(mYear<2006) { 00744 printf("\n AdjJPsum="); 00745 for(int i=Njp-1;i>=0; i--) printf(" %4d ",AdjJPsum[i]); 00746 } 00747 printf("\n"); 00748 printf("emul: orTPbit=%d orHTTPbit=%d \n",ee1outTPthrMax[0]||ee1outTPthrMax[1], ee1outHTTPthrMax[0] ||ee1outHTTPthrMax[1]); 00749 printf("\n\n----------- level-2 ----------------- \n"); 00750 ee2->print(); 00751 printf("\n\n----------- level-3 ( aka TCU) ----------- \n"); 00752 ee3->print(); 00753 } 00754 00755 //-------------------------------------------------- 00756 void EEdsmAna::printAllBarrel(int k) const { 00757 printf("\n\nBEdsmAna(%s)::print(eve=%d) , year=%d \n",myName,nTot,mYear); 00758 for(int i=0;i<Nbe2;i++) { 00759 printf("\n----------- level-2 BARREL Board %2d ",i+1); 00760 be2[i].print(); 00761 } 00762 printf("\n\n"); 00763 } 00764 00765 //-------------------------------------------------- 00766 void EEdsmAna::usePed(const Char_t *fName){ 00767 //......................... load ped for L-0 00768 LOG_INFO << "EEdsmAna(" << myName << ") reads pedestals from " << fName << endm; 00769 FILE *fd = fopen(fName, "r"); 00770 if (fd) { 00771 for (Int_t ibr = 0;ibr < Nee0;ibr++) { 00772 for (Int_t ch = 0;ch < ee0[ibr].getNc();ch++) { 00773 int a = 0, b = 0, c = 0; 00774 int ret = fscanf(fd, "%d %d %d", &a, &b, &c); 00775 if ((ret == 3) && (a == (ibr + 1)) && (b == ch)) { 00776 ped0[ibr][ch] = c; 00777 } else { 00778 LOG_ERROR << "Bad file format " << fName << ": got ret=" << ret << ", a=" << a << ", b=" << b << ", c=" << c << endm; 00779 } 00780 } 00781 } 00782 fclose(fd); 00783 fd = 0; 00784 } else { 00785 LOG_ERROR << "Cannot read file " << fName << endm; 00786 } 00787 } 00788 00789 void EEdsmAna::saveHisto(TFile *f) const { 00790 if (f) f->cd(); 00791 00792 00793 // .................level-0 input, 2D, HT .............. 00794 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00795 if (H0inHT[iJ]) H0inHT[iJ]->Write(); 00796 } 00797 00798 if (H0inHTall) H0inHTall->Write(); 00799 00800 // ........level-0 input, 2D, TP sum 00801 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00802 if (H0inTP[iJ]) H0inTP[iJ]->Write(); 00803 } 00804 00805 if (H0inTPall) H0inTPall->Write(); 00806 00807 // .................level-1 input, 2D 00808 //================================ TP 00809 00810 for(int iJ = 0;iJ < EEnHalfJetPatch;iJ++) { 00811 if (H1inTPvEmu[iJ]) H1inTPvEmu[iJ]->Write(); 00812 } 00813 00814 //================================ HT 00815 for(int iJ = 0;iJ < EEnHalfJetPatch;iJ++) { 00816 if (H1inHTvEmu[iJ]) H1inHTvEmu[iJ]->Write(); 00817 } 00818 00819 // .................level-2 input 00820 00821 //================================ HT 00822 for(int iJ = 0;iJ < EEnHalf;iJ++) { 00823 if (H2inHTTP[iJ]) H2inHTTP[iJ]->Write(); 00824 } 00825 00826 //================================ half Etot sum 00827 for(int iJ = 0;iJ < EEnHalf;iJ++) { 00828 if (H1inEtot[iJ]) H1inEtot[iJ]->Write(); 00829 } 00830 00831 // Total energy histos 00832 for(int iJ = 0;iJ < mxEtotBit;iJ++) { 00833 if (HEetot[iJ]) HEetot[iJ]->Write(); 00834 00835 if (HBetot[iJ]) HBetot[iJ]->Write(); 00836 00837 if (HBEetot[iJ]) HBEetot[iJ]->Write(); 00838 } 00839 00840 // .................level-3 input 00841 //================================ HT 00842 if (H3inHTTP) H3inHTTP->Write(); 00843 00844 //..................Jet Patch sums 00845 //=================================summed patch spectra 00846 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00847 if (H4jpSums[iJ]) H4jpSums[iJ]->Write(); 00848 } 00849 00850 //=================================Jet patch over threshold 00851 for (int iJ = 0;iJ < EEnThresh;iJ++) { 00852 if (H4jpFreq[iJ]) H4jpFreq[iJ]->Write(); 00853 } 00854 00855 //=================================summed adjacent patch spectra 00856 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00857 if (H4adjpSums[iJ]) H4adjpSums[iJ]->Write(); 00858 } 00859 00860 //=================================adjacent patch correlation 00861 for(int iJ = 0;iJ < EEnJetPatch;iJ++) { 00862 if (H4adjPcor[iJ]) H4adjPcor[iJ]->Write(); 00863 } 00864 00865 { //====================freq summed adjacent patch spectra over thresh 00866 if (H4adjpFreq) H4adjpFreq->Write(); 00867 } 00868 00869 { 00870 // added in 2005 00871 if (H5jpPed) H5jpPed->Write(); 00872 } 00873 00874 { 00875 if (H5jpFreq) H5jpFreq->Write(); 00876 00877 if (H5jpHot) H5jpHot->Write(); // is _not_ filled by sorter 00878 } 00879 } 00880

Generated on Sun Mar 15 04:51:24 2009 for StRoot by doxygen 1.3.7