Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

EDAnalysis.cxx

Go to the documentation of this file.
00001 
00002 #include "TSystem.h"
00003 #include "TStyle.h"
00004 
00005 #include "bfemDisplay/EDControl.h"
00006 #include "bfemDisplay/EDAnalysis.h"
00007 #include "bfemDisplay/Enum.h"
00008 #include "bfemDisplay/EDHistos.h"
00009 
00010 
00011 TH1 *hACD[13];
00012 TH1 *hXGT[4];
00013 TH1 *hTKR[26];
00014 TH1 *hTKRtotL[26];
00015 TH1 *hTKRtotR[26];
00016 
00017 TH1F *LOGID;
00018 TH1F *NLOGS;
00019 TH1F *BESTRANGE;
00020 TH1F *ELOG;
00021 TH1F *ETOTADCCAL;
00022 TH1F *ETOTCAL;
00023 TH1F *ADC0;
00024 TH1F *ADC1;
00025 TH1F *ADC2;
00026 TH1F *ADC3;
00027 TH2F *ETOTVSNLOGS;
00028 
00029 
00030 extern EDControl  *m_evtCtrl;   // Pointer to event control.
00031 
00032 EDHistos *h;             // Pointer to histos.
00033 
00034 ClassImp(EDAnalysis)
00035 
00036 
00037 EDAnalysis::EDAnalysis()
00038 
00039 {
00040 
00041   fTree = m_evtCtrl->getRawTree();
00042 
00043   event = m_evtCtrl->getEvent();
00044 
00045   h = m_evtCtrl->getHistos();
00046 
00047   m_ped = m_evtCtrl->getCALPeds();
00048 
00049   m_rawdata = m_evtCtrl->getRawDataType(); // Get type of input data: real or mc.
00050 
00051 
00052   m_StartEvent = 0;
00053 
00054 }
00055 
00056 
00057 void EDAnalysis::StartWithEvent(Int_t event) {
00058 
00059 // set a starting event for Go.
00060 
00061   m_StartEvent = event;
00062 
00063 }
00064 
00065 
00066 
00067 
00068 void EDAnalysis::Rewind()
00069 
00070 {
00071 
00072   //   Start input file at beginning
00073 
00074        m_StartEvent = 0;
00075 
00076        return;
00077 
00078 } 
00079 
00080 
00081 
00082 
00083 void EDAnalysis::Go(Int_t numEvents)
00084 
00085 {
00086   
00087   TH1F *hist;
00088   
00089   // Event loop_______________________________________ 
00090   
00091 
00092   fTree = m_evtCtrl->getRawTree();
00093 
00094   event = m_evtCtrl->getEvent();
00095 
00096   m_rawdata = m_evtCtrl->getRawDataType(); 
00097 
00098   if ( fTree == 0 ) return;
00099 
00100   if ( event ) event->Clean();
00101   
00102   
00103   Int_t nentries;
00104     
00105   nentries = m_evtCtrl->getEntries();
00106   
00107   
00108   printf("\nNum Events in File is: %i\n", nentries);
00109   
00110   Int_t curI;
00111   
00112   Int_t nMax = TMath::Min(numEvents+m_StartEvent,nentries);
00113   
00114   if (m_StartEvent == nentries) {
00115     
00116     printf(" all events in file read\n");
00117     
00118     return;
00119 
00120   }
00121 
00122 
00123 
00124   // Refresh histogram pointers_______________________________________
00125 
00126 
00127 
00128   TFile *histFile = (TFile*)gROOT->GetFile("Histograms.root");
00129 
00130 
00131   ADC0 = (TH1F*)histFile->Get("ADC0");
00132 
00133   ADC1 = (TH1F*)histFile->Get("ADC1");
00134 
00135   ADC2 = (TH1F*)histFile->Get("ADC2");
00136 
00137   ADC3 = (TH1F*)histFile->Get("ADC3");
00138 
00139   LOGID = (TH1F*)histFile->Get("LOGID");
00140 
00141   BESTRANGE = (TH1F*)histFile->Get("BESTRANGE");
00142 
00143   ELOG = (TH1F*)histFile->Get("ELOG");
00144 
00145   ETOTVSNLOGS = (TH2F*)histFile->Get("ETOTVSNLOGS");
00146 
00147   NLOGS = (TH1F*)histFile->Get("NLOGS");
00148 
00149   ETOTCAL = (TH1F*)histFile->Get("ETOTCAL");
00150 
00151   ETOTADCCAL = (TH1F*)histFile->Get("ETOTADCCAL");
00152 
00153   for (Int_t iacd = 0; iacd < NUM_ACD_HISTS; ++iacd) {
00154 
00155     hACD[iacd] = (TH1*)h->m_histList->At(iacd);
00156 
00157   }
00158 
00159   for (Int_t ixgt = 0; ixgt < NUM_XGT_HISTS; ++ixgt) {
00160 
00161     hXGT[ixgt] = (TH1*)h->m_histList->At(ixgt+13);
00162 
00163   }
00164 
00165   for (Int_t ilayer = 0; ilayer < NUM_TKR_HISTS; ++ilayer) {
00166 
00167     hTKR[ilayer] = (TH1*)h->m_histList->At(ilayer+28);
00168     
00169     hTKRtotL[ilayer] = (TH1*)h->m_histList->At(ilayer+54);
00170     
00171     hTKRtotR[ilayer] = (TH1*)h->m_histList->At(ilayer+80);
00172   }
00173 
00174   // Start analysis code _______________________________________
00175 
00176   m_Stop = kFALSE;
00177 
00178   for (Int_t ievent=m_StartEvent; ievent<nMax; ievent++, curI=ievent) {
00179 
00180 
00181     gSystem->ProcessEvents();
00182 
00183     if ( m_Stop ) break;
00184 
00185     if (event) event->Clean();
00186 
00187     if ( !( ievent%10 ) ) m_evtCtrl->UpdateGuiEvents( ievent );  // Update slider and event count.
00188 
00189     if ( ievent==100 ) m_evtCtrl->UpdateCanvas();  // Show a few preliminary events in histos.
00190 
00191     if ( !( ievent%1000 ) ) m_evtCtrl->UpdateCanvas();   // Update histos every 1000 events.
00192 
00193     if (ievent %100 == 0) printf(" Event: %i\n ", ievent);
00194 
00195     fTree->GetEvent(ievent);
00196 
00197    
00199     // ACD
00201 
00202     AcdTile *iTile;
00203 
00204     Int_t kADC = 1;
00205 
00206     if(kADC) {
00207 
00208       Int_t nACD = event->getAcdDigi()->GetEntries();
00209 
00210       Float_t eTotalACD;        
00211           
00212       for (Int_t ihit=0; ihit < nACD; ihit++) {   
00213  
00214         event->getAcdDigi()->Sort();
00215 
00216         AcdTile *hit = (AcdTile*)event->getAcdDigi()->At(ihit);
00217 
00218         AcdId *tile = (AcdId*) hit->getId();
00219 
00220         UInt_t id = tile->getId();
00221 
00222         if (id >1000) continue;
00223 
00224         iTile = ( AcdTile* )event->getAcdTile(id);
00225 
00226         eTotalACD = (Float_t) iTile->getPulseHeight();
00227 
00228         hist = (TH1F*)hACD[ihit];
00229 
00230         hist->Fill(eTotalACD);
00231 
00232       }
00233 
00234     }
00235 
00236 
00238     // XGT
00240 
00241 
00242     Int_t kXGT = 1;
00243 
00244     if(kXGT) {
00245 
00246       Int_t nXGT = event->getXgtDigi()->GetEntries();
00247           
00248       for (Int_t ihit=0; ihit < nXGT; ihit++) {   
00249  
00250         event->getXgtDigi()->Sort();
00251 
00252         AcdTile *hit = (AcdTile*)event->getXgtDigi()->At(ihit);
00253 
00254         AcdId *xgt = (AcdId*) hit->getId();
00255 
00256         Int_t id = xgt->getId();
00257 
00258         Float_t eTotalXGT;
00259 
00260         iTile = ( AcdTile* )event->getXgt(id);
00261 
00262         eTotalXGT = iTile->getPulseHeight();
00263 
00264         hist = (TH1F*)hXGT[ihit];
00265 
00266         hist->Fill(eTotalXGT);
00267 
00268       }
00269 
00270     }
00271 
00272 
00273 
00275 
00276     // Tracker...
00277 
00279 
00280 
00281 
00282     Int_t kTKR = 1;
00283 
00284     if(kTKR) {  
00285 
00286       event->getTkrDigi()->Sort();
00287 
00288       int nTKR = event->getTkrDigi()->GetEntries();
00289 
00290       for (Int_t ilay = 0; ilay < nTKR; ilay++) {
00291 
00292         const TkrLayer* layer = event->getTkrLayer(ilay); 
00293 
00294         // getXY = 0 measures Y ==> strips along X
00295         
00296         //      Int_t isY = (Int_t)layer->getXY();
00297 
00298         Int_t LayerNum= layer->getLayerNum();
00299        
00300  
00301         hist = (TH1F*)hTKR[LayerNum];       
00302             
00303         TObjArray  *stripList = 0;
00304             
00305         stripList = ( ( TkrLayer* )layer )->getStrips();
00306 
00307         Int_t nStrips = stripList->GetEntries();
00308 
00309         for (Int_t iStrip=0; iStrip < nStrips; iStrip++) {
00310 
00311           StripId* strip = (StripId*)(stripList->At(iStrip));
00312 
00313           Int_t stripID = strip->getId();
00314 
00315           if (stripID <=1600) hist->Fill(stripID);
00316 
00317         }
00318 
00319         Int_t totR =  ( ( TkrLayer* )layer )->getToT(0);
00320          
00321         Int_t totL =  ( ( TkrLayer* )layer )->getToT(1);
00322 
00323         hist = (TH1F*)hTKRtotL[LayerNum];
00324             
00325         if (totL) hist->Fill(totL);
00326 
00327         hist = (TH1F*)hTKRtotR[LayerNum];
00328             
00329         if (totR) hist->Fill(totR);
00330 
00331       }
00332       
00333     }
00334 
00335 
00336 
00338 
00339     // Calorimeter...
00340 
00342 
00343 
00344 
00345     Int_t kCAL = 1;
00346 
00347     if(kCAL) {  
00348 
00349       Int_t nCAL = event->getCalDigi()->GetEntries();
00350 
00351       Int_t nLOGS = 0;
00352 
00353       Float_t eLog = 0;
00354 
00355       Float_t eTotcal = 0, eTotadc = 0;
00356 
00357       Int_t index;
00358 
00359       //Float_t gain[4] = {0.000065, 0.00022, 0.0037, 0.022};
00360       Float_t gain[4] = {0.000075, 0.0003, 0.0043, 0.025};       //Eric's gain Sept. 11 2001  - in MeV
00361          
00362       
00363       for (Int_t ihit=0; ihit < nCAL; ihit++) {
00364 
00365         Int_t En = 1;
00366 
00367         CalLog *hitcal = (CalLog*) event->getCalDigi()->At(ihit);       
00368 
00369         LogId *log = (LogId*)hitcal->getLogId();
00370 
00371         Int_t id = log->getId(); // ==> id differs from the old id! range now from 0 to 39
00372 
00373         Int_t lay = log->getLayer();
00374 
00375         Int_t column = log->getColumn();
00376 
00377         Int_t iped = lay*10+column;
00378 
00379         Int_t hitADC;
00380 
00381 
00382         ((TH1*)h->m_histList->At(17))->Fill(id); // LOGID
00383            
00384            
00385 
00386         for (Int_t end=0; end <= 1; end++) {
00387              
00388                      
00389           Float_t eMax = -1000.; Int_t bestRange = -1;
00390 
00391           for (Int_t adc = 0; adc <= 3; adc++) {
00392 
00393             if (!end) hitADC = 4095 - hitcal->getAdc(hitcal->POS,adc);
00394             else hitADC = 4095 - hitcal->getAdc(hitcal->NEG,adc);
00395 
00396             if (hitADC < 1) continue;
00397 
00398             if(adc == 0) ((TH1*)h->m_histList->At(23))->Fill(hitADC); // ADC0
00399 
00400             if(adc == 1) ((TH1*)h->m_histList->At(24))->Fill(hitADC); // ADC1
00401 
00402             if(adc == 2) ((TH1*)h->m_histList->At(25))->Fill(hitADC); // ADC2
00403 
00404             if(adc == 3) ((TH1*)h->m_histList->At(26))->Fill(hitADC); // ADC3
00405 
00406             if (hitADC > 3900) continue;
00407 
00408             if (hitADC > eMax) {
00409 
00410               eMax = hitADC;
00411 
00412               bestRange = adc;
00413 
00414             }
00415 
00416           }
00417 
00418 
00419 
00420           if(!end) index = 2 * bestRange;
00421 
00422           else index = 2 * bestRange + 1;
00423 
00424           // Correct for unexpected ordering in ROOT ped file.
00425           
00426           /*      if(index==1) index=2;
00427           
00428                   if(index==2) index=1;*/
00429 
00430 
00431 
00432           ((TH1*)h->m_histList->At(19))->Fill(bestRange); // BESTRANGE
00433 
00434           Float_t eHit;
00435 
00436           if (bestRange > -1) {
00437 
00438             if ( m_rawdata ) {  // real raw data 
00439 
00440 
00441             if ( m_ped ) {
00442                
00443               TVector *vv = (TVector *)m_ped->At(index);
00444                                
00445               Float_t calped = vv->operator()( iped );
00446 
00447               eHit = (eMax-calped)*gain[bestRange];
00448 
00449               if (eHit < 0) En = 0;
00450 
00451             }
00452 
00453             else { eHit = 0; En = 0; }
00454             }
00455 
00456             else { // mc data
00457 
00458               eHit = eMax*gain[bestRange];
00459               if (eHit <= 0) En = 0;
00460 
00461             }
00462 
00463             eLog += eHit/2.;
00464 
00465             eTotadc += eMax/2.;       
00466 
00467 
00468           }
00469 
00470         }
00471 
00472         if (En) {
00473 
00474           ((TH1*)h->m_histList->At(20))->Fill(eLog); // ELOG
00475 
00476           eTotcal += eLog;
00477 
00478           nLOGS++;
00479 
00480         }
00481 
00482         eLog = 0;
00483 
00484       } // End CAL logs loop
00485 
00486          
00487 
00488       if (eTotcal > 0) ((TH1*)h->m_histList->At(22))->Fill(eTotcal); // ETOTCAL
00489       
00490       ((TH1*)h->m_histList->At(21))->Fill(eTotadc); // ETOTADCCAL
00491 
00492       ((TH1*)h->m_histList->At(18))->Fill(nLOGS); // NLOGS
00493 
00494       ((TH1*)h->m_histList->At(27))->Fill(eTotadc,(Float_t)nLOGS); // ETOTVSNLOGS
00495 
00496               
00497 
00498     }
00499 
00500 
00501   } // End event loop
00502 
00503   // end analysis code in event loop ___________________________
00504 
00505 
00506   histFile->Write();
00507 
00508   if ( !( curI%10 ) )m_evtCtrl->UpdateGuiEvents( curI );
00509 
00510   m_StartEvent = curI;
00511 
00512       
00513 
00514   cout << "\nAnalysis finished at event " << curI << ".\n";
00515 
00516 
00517 } // End GO()
00518 
00519 
00520 
00521 
00522 
00523 
00524 
00525 
00526 
00527 
00528 
00529 
00530 
00531 
00532 

Generated at Wed Nov 14 20:41:42 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000