STEER/TFndHdt.cxx

00001 // @(#)fROOT/STEER:$Name:  $:$Id: TFndHdt.cxx,v 1.32 2007/09/24 07:32:41 Diego_Faso Exp $
00002 // Revision Author: Diego Faso <mailto:faso@to.infn.it>, 2005/06/24
00003 // Original Author: Piergiorgio Cerello, 2001
00004 
00006 //                               TFndHdt                               //
00007 //                                                                     //
00008 // This class gives the Description of the Hit Data Tape event:        //
00009 // it contains a set of pointers to Arrays of hit objects for          //
00010 // different detectors, a pointer to a Header object, a pointer        //
00011 //                                                                     //
00012 //      to the Trigger object and a set of integers giving             //
00013 // the number of hits for each detector and the total number of hits   //
00014 //                                                                     //
00016 
00017 #include "TFndHdt.h"
00018 //#include "TFndRunConfiguration.h"
00019 //#include "TFile.h"
00020 //#include "TObjectTable.h"
00021 
00022 ClassImp(TFndHdt)
00023 
00024 TClonesArray *TFndHdt::fgHTof = 0;
00025 TClonesArray *TFndHdt::fgHSilCluster = 0;
00026 TClonesArray *TFndHdt::fgHLmd = 0;
00027 TClonesArray *TFndHdt::fgHStb = 0;
00028 
00029 //___________________________________________
00030 TFndHdt::TFndHdt()
00031   :fRunNumber(),fEvtNum(),
00032    fNoiseLevel(-999)
00033    
00034 {
00035   SetSilComMod_meanmaxcount_zero();
00036 
00037   fGts = new TFndTrig();
00038   if (!fgHTof) fgHTof = new TClonesArray("TFndHTof",84);
00039   fTofHits = fgHTof;
00040   
00041   if (!fgHSilCluster) fgHSilCluster = new TClonesArray("TFndHSilCluster",100);
00042   fSilClusters = fgHSilCluster;
00043   
00044   if (!fgHLmd) fgHLmd = new TClonesArray("TFndHLmd",272);
00045   fLmdHits = fgHLmd;
00046   
00047   if (!fgHStb) fgHStb = new TClonesArray("TFndHStb",2404);
00048   fStbHits = fgHStb;
00049   
00050 }
00051 
00052 //___________________________________________
00053 TFndHdt::~TFndHdt()
00054 { 
00055   ClearArrays();
00056   Reset();
00057   delete fGts; fGts = 0;
00058   //  delete fTofHits; fTofHits = 0;
00059 
00060   //   delete fGts; fGts = 0;
00061   //   delete fgHTof; fgHTof = 0;
00062   //   delete fgHSilCluster; fgHSilCluster = 0;
00063   //   delete fgHLmd; fgHLmd = 0;
00064   //   delete fgHStb; fgHStb = 0;
00065 } 
00066 
00067 //___________________________________________
00068 void TFndHdt::ClearArrays(){
00069 
00070   fRunNumber = 0;
00071   fEvtNum = 0;
00072   fNoiseLevel = -999;
00073   //
00074   fGts->Reset();
00075   // ---
00076   fTofHits->Clear();
00077   //
00078   SetSilComMod_meanmaxcount_zero();
00079   fSilClusters->Clear();
00080   //
00081   fLmdHits->Clear();
00082   //
00083   fStbHits->Clear();
00084   
00085   //  TCollection::EmptyGarbageCollection(); // to be tested
00086 }
00087 
00088 //___________________________________________
00089 void TFndHdt::Reset(){
00090 
00091   fRunNumber = 0;
00092   fEvtNum = 0;
00093   fNoiseLevel = -999;
00094   //
00095   fGts->Reset();
00096   // ---
00097   fTofHits->Delete();
00098   //
00099   SetSilComMod_meanmaxcount_zero();
00100   fSilClusters->Delete();
00101   //
00102   fLmdHits->Delete();
00103   //
00104   fStbHits->Delete();
00105   
00106   //  TCollection::EmptyGarbageCollection(); // to be tested
00107 }
00108 
00109 //___________________________________________
00110 TFndHTof *TFndHdt::Find_Add_TofHit(Int_t channel,Bool_t add_if_missing){
00111   
00112   Int_t last_id = fTofHits->GetEntries();
00113   for(Int_t i=0;i<last_id;i++)
00114     if( ((TFndHTof*)fTofHits->At(i))->GetChannel() == channel){
00115       //      Printf("TFndHdt::Find_Add_TofHit ---> Hit found at position %d (channel %d)",i,channel);
00116       return ((TFndHTof*)fTofHits->At(i));
00117     }
00118   
00119   if(!add_if_missing){
00120     Info("Find_Add_TofHit","No hit found for channel %d",channel);
00121     return 0;
00122   }
00123   
00124   TClonesArray &tof_hits = *fTofHits;
00125   TFndHTof *th = new(tof_hits[last_id]) TFndHTof(channel);
00126   //  Printf("TFndHdt::Find_Add_TofHit ---> Hit added at position %d (channel %d)",last_id,channel);
00127   return th;
00128   
00129 }
00130 
00131 //___________________________________________
00132 TFndHSilCluster *TFndHdt::Add_SilCluster(Int_t layer){
00133   // the "Find" step is dummy (kept for compatibility of method names)
00134   // ...still thinking if s SilCluster can be univocally identified
00135 
00136   Int_t last_id = fSilClusters->GetEntries();
00137   
00138   TClonesArray &sil_hits = *fSilClusters;
00139   TFndHSilCluster *sch = new(sil_hits[last_id]) TFndHSilCluster(layer);
00140   //  Printf("TFndHdt::Find_Add_SilCluster ---> Hit added at position %d (channel %d)",last_id,channel);
00141   return sch;
00142   
00143 }
00144 
00145 //___________________________________________
00146 TFndHLmd *TFndHdt::Find_Add_LmdHit(Int_t channel,Bool_t add_if_missing){
00147   
00148   Int_t last_id = fLmdHits->GetEntries();
00149   for(Int_t i=0;i<last_id;i++)
00150     if( ((TFndHLmd*)fLmdHits->At(i))->GetChannel() == channel){
00151       //      Printf("TFndHdt::Find_Add_LmdHit ---> Hit found at position %d (channel %d)",i,channel);
00152       return ((TFndHLmd*)fLmdHits->At(i));
00153     }
00154   
00155   if(!add_if_missing){
00156     Info("Find_Add_LmdHit","No hit found for channel %d",channel);
00157     return 0;
00158   }
00159   
00160   TClonesArray &lmd_hits = *fLmdHits;
00161   TFndHLmd *lh = new(lmd_hits[last_id]) TFndHLmd(channel);
00162   //  Printf("TFndHdt::Find_Add_LmdHit ---> Hit added at position %d (channel %d)",last_id,channel);
00163   return lh;
00164 
00165   
00166 }
00167 
00168 //___________________________________________
00169 TFndHStb *TFndHdt::Find_Add_StbHit(Int_t channel,Bool_t add_if_missing){
00170   
00171   Int_t last_id = fStbHits->GetEntries();
00172   for(Int_t i=0;i<last_id;i++)
00173     if( ((TFndHStb*) fStbHits->At(i))->GetChannel() == channel){
00174       if(add_if_missing) Warning("Find_Add_StbHit","Hit found at position %d (channel %d)",i,channel);
00175       return ((TFndHStb*) fStbHits->At(i));
00176     }
00177   
00178   if(!add_if_missing){
00179     Info("Find_Add_StbHit","No hit found for channel %d",channel);
00180     return 0;
00181   }
00182   TClonesArray &stb_hits = *fStbHits;
00183   TFndHStb *sh = new(stb_hits[last_id]) TFndHStb(channel);
00184   //  Printf("TFndHdt::Find_Add_StbHit ---> Hit added at position %d (channel %d)",last_id,channel);
00185   return sh;
00186 
00187 }
00188 
00189 //___________________________________________
00190 void TFndHdt::EvalHits(){
00191   // eval hits positions, SIL clusters, calibrations, "both flags", etc...
00192   
00193   for(Int_t ic = 0 ; ic < fTofHits->GetEntries() ; ic++) ( (TFndHTof *)fTofHits->At(ic) )->EvalHit();
00194   for(Int_t ic = 0 ; ic < fSilClusters->GetEntries() ; ic++) ( (TFndHSilCluster *)fSilClusters->At(ic) )->EvalHit();  
00195   for(Int_t ic = 0 ; ic < fLmdHits->GetEntries() ; ic++) ( (TFndHLmd*) fLmdHits->At(ic) )->EvalHit();
00196   for(Int_t ic = 0 ; ic < fStbHits->GetEntries() ; ic++) ( (TFndHStb*) fStbHits->At(ic) )->EvalHit();
00197   
00198   EvalNoiseLevel(); 
00199 }
00200 
00201 //___________________________________________
00202 void TFndHdt::EvalNoiseLevel(){
00203   // Event noise level evaluated looking at TOFINO hits
00204   //
00205   //                 //  -3: One slab only: event lost (rejected by charge cut + BtB)
00206   //                 //  -2: One slab only: event lost (rejected by charge cut)
00207   //                 //  -1: One slab only: event lost (trigger error)
00208   //                 //   0: MT-selection ( already BtB )
00209   //                 //   1: MT-selection + BtB
00210   //                 //   2: MT-selection + BtB + CHARGE cut
00211   //                 //   3: MT-selection + BtB + CHARGE cut + BtB
00212   //                 // 4-9: not used (free for further development)
00213   //                 //  10: Further selection needed (ISIM...)
00214   //  
00215   // NOTE: meaningful for Hype events only
00216 
00217   const Int_t nsl = K_N_TOFINO_SLABS; // just for convenience
00218 
00219   TFndHTof *tmptof = 0;
00221 
00222   Bool_t fIsHighMeanTime[nsl];
00223   Bool_t fIsLowMeanTime[nsl];
00224   Bool_t fIsHighAdc[nsl];
00225   
00226   // following arreys are used alternatively
00227   // during consecutive selection steps
00228   //    (they depend on each other)
00229   Bool_t fIsSelected_A[nsl]; // odd  selections
00230   Bool_t fIsSelected_B[nsl]; // even selections
00231 
00232   for(Int_t i=0; i<nsl; i++){
00233     fIsHighMeanTime[i] = kFALSE;
00234     fIsLowMeanTime[i]  = kFALSE;
00235     fIsHighAdc[i]      = kFALSE;
00236     //
00237     fIsSelected_A[i]   = kFALSE;
00238     fIsSelected_B[i]   = kFALSE;
00239   }
00240 
00241   // --- inspect all hits
00242   Int_t nhits = fTofHits->GetEntries();
00243   for(Int_t nh=0; nh<nhits; nh++){ // loop on TOF hits
00244     tmptof = ( (TFndHTof *)fTofHits->At(nh) );
00245     if(!tmptof){
00246       Error("EvalNoiseLevel","Maybe you have just found a BUG!!!");
00247       TerminateFroot();
00248     }
00249     Int_t lay = tmptof->GetLayer();
00250     Int_t slab = tmptof->GetSlab();
00251     if(lay != E_FIN_INNER_LAYER || slab < 1 || slab > nsl) continue;
00252     // tofino hits have been selected
00253     // ---
00254     if(tmptof->GetHighMeanTimer() > -1) fIsHighMeanTime[slab-1] = kTRUE;
00255     if(tmptof->GetLowMeanTimer() > -1) fIsLowMeanTime[slab-1] = kTRUE;
00256     
00257     //     Float_t chrg = tmptof->GetEnergyDep();
00258     //     if( chrg > K_EN_THR[slab-1]) fIsHighAdc[slab-1] = kTRUE;
00259     Float_t overchrg = tmptof->GetOverChargeValue();
00260     if( overchrg > 0 ) fIsHighAdc[slab-1] = kTRUE;
00261   } // hits loop completed
00262   
00263   // 
00264   // --- check obtained results
00265   //
00266 
00267   Int_t nsel = -1; // number of selected slabs (after every selection step)
00268   
00269   // --- first selection (mean-timer) (sel n.1 : A)
00270   nsel = 0;
00271   for(Int_t i=0; i<nsl; i++){
00272     if( fIsHighMeanTime[i] ){
00273       fIsSelected_A[i] = kTRUE;
00274       nsel++;
00275     }
00276     else fIsSelected_A[i] = kFALSE;
00277   }
00278   // ---
00279   if(nsel < 2){ 
00280     fNoiseLevel = -1;
00281     return;
00282   }  
00283   Bool_t isgood = kFALSE; // used before BtB selection
00284   if(nsel == 2){ 
00285     isgood = kTRUE;
00286   }
00287   // --- check trigger extended-btb (sel n.2 : B)
00288   for(Int_t i=0; i<nsl; i++) fIsSelected_B[i] = kFALSE;
00289   for(Int_t i=0; i<nsl; i++) {
00290     for(Int_t j=0; j<nsl; j++) {
00291       if(i!=j && fIsSelected_A[i] && fIsSelected_A[j] ) {
00292         if( CheckTofinoBtb(i,j)){
00293           fIsSelected_B[i] = kTRUE;
00294           fIsSelected_B[j] = kTRUE;
00295         }
00296       }
00297     }
00298   }
00299   //
00300   // --- 
00301   nsel = 0;
00302   for(Int_t i=0; i<K_N_TOFINO_SLABS; i++){
00303     if( fIsSelected_B[i] ) nsel++; 
00304   }
00305   // ---
00306   if( nsel == 2 ){
00307     fNoiseLevel = (isgood) ? 0 : 1;
00308     return;
00309   } 
00310   else if(nsel < 2){
00311     fNoiseLevel = -1;
00312     return;
00313   }
00314   // --- check charge  (sel n.3 : A)
00315   isgood = kFALSE;
00316   nsel = 0;
00317   for(Int_t i=0; i<nsl; i++) {
00318     if( fIsSelected_B[i] && fIsHighAdc[i] ){
00319       fIsSelected_A[i] = kTRUE;
00320       nsel++;
00321     }
00322     else  fIsSelected_A[i] = kFALSE;
00323   }
00324   // ---
00325   if(nsel < 2){
00326     fNoiseLevel = -2;
00327     return;
00328   }  
00329   if(nsel == 2){ 
00330     isgood = kTRUE;
00331   }
00332   // --- check trigger extended-btb (sel n.4 : B)
00333   for(Int_t i=0; i<nsl; i++) fIsSelected_B[i] = kFALSE;
00334   for(Int_t i=0; i<nsl; i++) {
00335     for(Int_t j=0; j<nsl; j++) {
00336       if( i !=j && fIsSelected_A[i] && fIsSelected_A[j] ) {
00337         if( CheckTofinoBtb(i,j)){
00338           fIsSelected_B[i] = kTRUE;
00339           fIsSelected_B[j] = kTRUE;
00340         }
00341       }
00342     }
00343   }
00344   //
00345   // --- 
00346   nsel = 0;
00347   for(Int_t i=0; i<K_N_TOFINO_SLABS; i++){
00348     if( fIsSelected_B[i] ) nsel++; 
00349   }
00350   // ---
00351   if( nsel == 2 ){
00352     fNoiseLevel = (isgood) ? 2 : 3;
00353     return;
00354   } 
00355   else if(nsel < 2){
00356     fNoiseLevel = -3;
00357     return;
00358   }
00359   fNoiseLevel = 999;
00360 
00361   // ---
00362   tmptof = 0;
00363 }
00364 
00365 //___________________________________________
00366 void TFndHdt::PrintHits(Int_t dpt_gts,Int_t dpt_tof,Int_t dpt_sil,Int_t dpt_lmd,Int_t dpt_stb) {
00367   // Print all hits (depending on the given depth-level)
00368   // Set "depth = -1" in order to disable printing for a specific detector
00369   
00370   TString msg = "";
00371   TString cline = "";
00372   
00373   cline.Form("\n\n TFndHdt::PrintHits - run %u , event %u\n",fRunNumber,fEvtNum); msg+=cline;
00374   cline.Form("  -> Print depth level for GTS is: %d \n",dpt_gts); msg+=cline;
00375   cline.Form("  -> Print depth level for TOF is: %d \n",dpt_tof); msg+=cline;
00376   cline.Form("  -> Print depth level for SIL is: %d \n",dpt_sil); msg+=cline;
00377   cline.Form("  -> Print depth level for LMD is: %d \n",dpt_lmd); msg+=cline;
00378   cline.Form("  -> Print depth level for STB is: %d \n",dpt_stb); msg+=cline;
00379 
00380   cline.Form("  -> Event evaluated noise level : %d \n",fNoiseLevel); msg+=cline;
00381 
00382   Printf(msg);
00383   
00384   PrintGts(dpt_gts);
00385   PrintTofHits(dpt_tof);
00386   if(dpt_sil > 3) PrintSilHits(dpt_sil);
00387   PrintSilClusters(dpt_sil);
00388   PrintLmdHits(dpt_lmd);
00389   PrintStbHits(dpt_stb);
00390   
00391   Printf("\n TFndHdt::PrintHits - All hits printed for run %u , event %u",fRunNumber,fEvtNum);
00392 }
00393 
00394 //___________________________________________
00395 void TFndHdt::PrintGts(Int_t depth) {
00396 
00397   if(depth < 0) return;
00398   Printf("\nTFndHdt::PrintGts - event %u GTS content",fEvtNum);
00399   fGts->PrintTrigger(depth);
00400 
00401 }
00402 
00403 //___________________________________________
00404 void TFndHdt::PrintTofHits(Int_t depth) {
00405   
00406   if(depth < 0) return;
00407   Int_t entries = fTofHits->GetEntries();
00408   Printf("\nTFndHdt::PrintTofHits - event %u ; number of TOF Hits: %d",fEvtNum,entries);
00409   for(Int_t ic=0;ic<entries; ic++) {
00410     ( (TFndHTof *)fTofHits->At(ic) )->PrintHit(depth);
00411   } 
00412   
00413 }
00414 
00415 //___________________________________________
00416 void TFndHdt::PrintSilHits(Int_t depth){
00417   if(depth < 0) return;
00418   
00419   Printf("\nTFndHdt::PrintSilHits",fEvtNum);
00420   for(Int_t ch=0;ch<K_N_Sil_AdcCha;ch++){
00421     for(Int_t mod=0;mod<K_N_Sil_Modules;mod++){
00422       for(Int_t side=0;side<K_N_Sil_Sides;side++){
00423         Printf("  printing ch %d, mod %d, side %d",ch,mod,side);
00424         Printf("    -> Noise   : %d",fSilNoise[ch][mod][side]);
00425         Printf("    -> CM-mean : %d",fSilComMod_mean[ch][mod][side]);
00426         //      Printf("    -> CM-sigma: %d",fSilComMod_sigma[ch][mod][side]);
00427         //
00428       }
00429     }      
00430   }
00431   
00432 }
00433 
00434 //___________________________________________
00435 void TFndHdt::PrintSilClusters(Int_t depth){
00436 
00437   if(depth < 0) return;
00438   
00439   Int_t entries = fSilClusters->GetEntries();
00440   Printf("\nTFndHdt::PrintSilClusters - event %u ; number of Sil-clusters: %d",fEvtNum,entries);
00441   for(Int_t ic=0;ic<entries; ic++) {
00442     TFndHSilCluster *hit = (TFndHSilCluster*) fSilClusters->At(ic); 
00443     hit->PrintHit(depth);
00444   } 
00445   
00446 
00447 }
00448 
00449 //___________________________________________
00450 void TFndHdt::PrintLmdHits(Int_t depth) {
00451   
00452   if(depth < 0) return;
00453   Int_t entries = fLmdHits->GetEntries();
00454   Printf("\nTFndHdt::PrintLmdHits - event %u ; number of Drift Chambers Hits: %d",fEvtNum,entries);
00455   for(Int_t ic=0;ic<entries; ic++) {
00456     TFndHLmd *hit = (TFndHLmd*) fLmdHits->At(ic); 
00457     hit->PrintHit(depth);
00458   } 
00459   
00460 }
00461 
00462 //___________________________________________
00463 void TFndHdt::PrintStbHits(Int_t depth) {
00464 
00465   if(depth < 0) return;
00466 
00467   Int_t entries = fStbHits->GetEntries();
00468   Printf("\nTFndHdt::PrintStbHits - event %u ; number of Straw Tubes Hits: %d",fEvtNum,entries);
00469   for(Int_t id=0;id<entries; id++) {
00470     TFndHStb *hit = (TFndHStb*) fStbHits->At(id); 
00471     hit->PrintHit(depth);
00472   } 
00473   
00474 }

Generated on Tue Oct 16 15:40:48 2007 by  doxygen 1.5.2