STEER/TFndHdt.h

00001 // @(#)fROOT/STEER:$Name:  $:$Id: TFndHdt.h,v 1.32 2007/09/20 09:49:24 Diego_Faso Exp $
00002 // Revision Author: Diego Faso <mailto:faso@to.infn.it>, 2005/06/24
00003 // Original Author: Piergiorgio Cerello, 2001
00004 
00005 #ifndef FROOT_TFndHdt
00006 #define FROOT_TFndHdt
00007 
00009 //                               TFndHdt                               //
00010 //                                                                     //
00011 // This class gives the Description of the Hit Data Tape event:        //
00012 // it contains a set of pointers to Arrays of hit objects for          //
00013 // different detectors, a pointer to a Header object, a pointer        //
00014 //                                                                     //
00015 //      to the Trigger object and a set of integers giving             //
00016 // the number of hits for each detector and the total number of hits   //
00017 //                                                                     //
00019 
00020 //#include "TObject.h"
00021 #include "TThread.h"
00022 
00023 #include "TFndRun.h"
00024 #include "TFile.h"
00025 
00026 #include "TFndTrig.h"
00027 #include "TFndHTof.h"
00028 #include "TFndHSilCluster.h"
00029 #include "TFndHLmd.h"
00030 #include "TFndHStb.h"
00031 
00032 #include "FROOT.h"
00033 using namespace FROOT;
00034 
00035 #include "TClonesArray.h"
00036 
00037 class TFndHdt : public TObject {
00038 
00039  private:
00040   UInt_t fRunNumber;   // Run Number
00041   UInt_t fEvtNum;      // Event Number
00042 
00043   TFndTrig  *fGts; //-> Pointer to Finuda Trigger // May become TFndGTS
00044 
00045   TClonesArray *fTofHits;     //-> Container for TOF Hits 
00046 
00047   TClonesArray *fSilClusters; //-> Container for Silicon Clusters
00048 
00049   // AdcCha (0-1023) SilSides (0-2) SilModules (1-10) Layer (1-2)
00050   Int_t fSilNoise[(Int_t)K_N_Sil_AdcCha][(Int_t)K_N_Sil_Sides][(Int_t)K_N_Sil_Modules+1][(Int_t)E_FIN_OUTER_LAYER+1]; 
00051   Double_t fSilComMod_mean[(Int_t)K_N_Sil_AdcChips][(Int_t)K_N_Sil_Sides][(Int_t)K_N_Sil_Modules+1][(Int_t)E_FIN_OUTER_LAYER+1]; 
00052   //  Double_t fSilComMod_sigma[(Int_t)K_N_Sil_AdcChips][(Int_t)K_N_Sil_Sides][(Int_t)K_N_Sil_Modules+1][(Int_t)E_FIN_OUTER_LAYER+1]; //! temporary storage for SIL common-mode (sigma)
00053   Int_t fSilComMod_count[(Int_t)K_N_Sil_AdcChips][(Int_t)K_N_Sil_Sides][(Int_t)K_N_Sil_Modules+1][(Int_t)E_FIN_OUTER_LAYER+1]; 
00054   Double_t fSilComMod_max[(Int_t)K_N_Sil_AdcChips][(Int_t)K_N_Sil_Sides][(Int_t)K_N_Sil_Modules+1][(Int_t)E_FIN_OUTER_LAYER+1]; 
00055 
00056   TClonesArray *fLmdHits;     //-> Container for Drift-Chamber Hits  
00057   TClonesArray *fStbHits;     //-> Container for Straw Tubes Hits
00058   
00059   Int_t fNoiseLevel; // event noise level: steps for obtaining 2 slabs only
00060   //                 //-999: Initialization value: not set during evaluation
00061   //                 //  -3: One slab only: event lost (rejected by charge cut + BtB)
00062   //                 //  -2: One slab only: event lost (rejected by charge cut)
00063   //                 //  -1: One slab only: event lost (trigger error)
00064   //                 //   0: MT-selection ( already BtB )
00065   //                 //   1: MT-selection + BtB
00066   //                 //   2: MT-selection + BtB + CHARGE cut
00067   //                 //   3: MT-selection + BtB + CHARGE cut + BtB
00068   //                 // 4-9: not used (free for further development)
00069   //                 // 999: Further selection needed (ISIM...)
00070   // NOTE: meaningful for Hype events only
00071 
00072   // --- inline private methods
00073   
00074   void SetSilComMod_meanmaxcount_zero()
00075     {
00076       for(Int_t nchip = 0; nchip < (Int_t) K_N_Sil_AdcChips; nchip++)
00077         for(Int_t nside = 0; nside < (Int_t) K_N_Sil_Sides; nside++)
00078           for(Int_t nmod = 1; nmod < (Int_t) K_N_Sil_Modules+1; nmod++)
00079             for(Int_t nlay = 1; nlay < (Int_t) E_FIN_OUTER_LAYER+1; nlay++){
00080               SetSilComMod_mean(nchip, nside, nmod, nlay, 0.0);
00081               SetSilComMod_max(nchip, nside, nmod, nlay, 0.0);
00082               SetSilComMod_count(nchip, nside, nmod, nlay, 0);}
00083     }
00084   
00085   static Bool_t CheckTofinoBtb(const Int_t &sl_ref,const Int_t &sl_opp)
00086     { 
00087       UInt_t check = static_cast<UInt_t>( TMath::Abs(sl_ref-sl_opp) );
00088       if(check >=5 && check <=7) return kTRUE;
00089       return kFALSE;
00090     }
00091   
00092   void EvalNoiseLevel(); // evaluate noise level looking at TOFINO hits
00093 
00094  public:
00095   TFndHdt();          // Default Constructor
00096   ~TFndHdt();         // Destructor
00097   
00098   void ClearArrays(); // clear all obj-arrays without deleting it
00099   void Reset(); // reset this object without deleting it
00100   void SetEventProperties(const UInt_t &run_num,const UInt_t &evt_num)
00101     {
00102       fRunNumber = run_num;
00103       fEvtNum = evt_num;
00104     }
00105   
00106   UInt_t GetRunNumber() const { return fRunNumber; } // Get Run Number  
00107   UInt_t GetEventNumber() const { return fEvtNum;  } // Get Event Number
00108 
00109   void EvalHits(); // eval hits positions, SIL clusters, calibratioons, and anything else...
00110   Int_t GetNoiseLevel() { return fNoiseLevel; }
00111   // --- ther can be one Gts hit only for every event
00112   // void AddGtsHit(...arguments to be defined...)
00113   TFndTrig   *GetGts() { return fGts; } // Get Trigger pointer      
00114 
00115   // hits on every detector are threated in the same way (by using pointers TClonesArray)
00116   TClonesArray *GetTofHits() { return fTofHits; }
00117   Int_t GetNumberOfTofHits() const { return fTofHits->GetEntries(); }
00118   TFndHTof *GetTofHit(Int_t hit_id)    { return ((TFndHTof*) fTofHits->At(hit_id)); }
00119   TFndHTof *Find_Add_TofHit(Int_t channel,Bool_t add_if_missing=kFALSE);
00120 
00121   static Float_t GetTofinoChargeCut(const Int_t &nslab,const UInt_t &run_time)
00122     {
00123       if(nslab < 1 || nslab > K_N_TOFINO_SLABS){
00124         gROOT->Error("TFndHdt::GetTofinoChargeCut","nslab \"%d\"out of range",nslab);
00125         return 0;
00126       }
00127       Bool_t Is_2006_dtak = (run_time > FROOT::DTak_2006_SftwStartTime)? kTRUE : kFALSE ;
00128       
00129       // values taken from fidarc->reccde (v_603 - Aug 29, 2007)
00130       switch(nslab){
00131         // 2003 dtak ===> 1500.,1300.,2*1500.,1300.,5*1500.,2*1300.
00132         // 2006 dtak ===> 350.,400.,400.,450.,470.,590.,500.,500.,500.,300.,360.,400.
00133       case  1: return (Is_2006_dtak)? 350 : 1500;
00134       case  2: return (Is_2006_dtak)? 400 : 1300;
00135       case  3: return (Is_2006_dtak)? 400 : 1500;
00136       case  4: return (Is_2006_dtak)? 450 : 1500;
00137       case  5: return (Is_2006_dtak)? 470 : 1300;
00138       case  6: return (Is_2006_dtak)? 590 : 1500;
00139       case  7: return (Is_2006_dtak)? 500 : 1500;
00140       case  8: return (Is_2006_dtak)? 500 : 1500;
00141       case  9: return (Is_2006_dtak)? 500 : 1500;
00142       case 10: return (Is_2006_dtak)? 300 : 1500;
00143       case 11: return (Is_2006_dtak)? 360 : 1300;
00144       case 12: return (Is_2006_dtak)? 400 : 1300;
00145       default: return (Is_2006_dtak)? 0 : 0;
00146       }
00147     }
00148 
00149 
00150   // --- SILICON DETECTOR  
00151   TClonesArray *GetSilClusters() { return fSilClusters; }
00152   Int_t GetNumberOfSilClusters() const { return fSilClusters->GetEntries(); }
00153   TFndHSilCluster *GetSilCluster(Int_t sil_cluster_id) { return ((TFndHSilCluster*) fSilClusters->At(sil_cluster_id)); } // Get n-th SilCluster from HDT
00154   TFndHSilCluster *Add_SilCluster(Int_t layer);
00155   void SetSilNoise(Int_t Sil_AdcCha, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer, Int_t val){fSilNoise[Sil_AdcCha][Sil_Side][Sil_Module][Sil_Layer] = val;} 
00156   Int_t GetSilNoise(Int_t Sil_AdcCha, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer){return fSilNoise[Sil_AdcCha][Sil_Side][Sil_Module][Sil_Layer];} 
00157   void SetSilComMod_mean(Int_t Sil_AdcChip, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer, Double_t val){fSilComMod_mean[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] = val;}
00158   void FillSilComMod_mean(Int_t Sil_AdcChip, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer, Double_t val){ 
00159     if (val > fSilComMod_max[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer]) fSilComMod_max[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] = val; 
00160     fSilComMod_mean[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] += val; fSilComMod_count[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer]++;} 
00161   void CalculateSilComMod_mean(Int_t Sil_AdcChip, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer){
00162     (fSilComMod_count[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] > 1) ? (fSilComMod_mean[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] = ((fSilComMod_mean[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] - fSilComMod_max[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer]) / (Double_t) (fSilComMod_count[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] - 1.))) : 0;}   
00163 
00164 void CalculateSilComMod_mean_all(){ 
00165     for(Int_t nchip = 0; nchip < (Int_t) K_N_Sil_AdcChips; nchip++)
00166       for(Int_t nside = 0; nside < (Int_t) K_N_Sil_Sides; nside++)
00167         for(Int_t nmod = 1; nmod < (Int_t) K_N_Sil_Modules+1; nmod++)
00168           for(Int_t nlay = 1; nlay < (Int_t) E_FIN_OUTER_LAYER+1; nlay++)
00169             CalculateSilComMod_mean(nchip, nside, nmod, nlay);}
00170 
00171   Int_t GetIntSilComMod_mean(Int_t Sil_AdcChip, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer){ return lrint(fSilComMod_mean[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer]);}
00172   // void SetSilComMod_sigma(Int_t Sil_AdcChip, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer, Double_t val) {fSilComMod_sigma[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] = val;} 
00173   void SetSilComMod_count(Int_t Sil_AdcChip, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer, Int_t val) {fSilComMod_count[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] = val;} 
00174   void SetSilComMod_max(Int_t Sil_AdcChip, Int_t Sil_Side, Int_t Sil_Module, Int_t Sil_Layer, Double_t val) {fSilComMod_max[Sil_AdcChip][Sil_Side][Sil_Module][Sil_Layer] = val;} 
00175 
00176   // ---
00177   
00178   TClonesArray *GetLmdHits() { return fLmdHits; }
00179   Int_t GetNumberOfLmdHits() const { return fLmdHits->GetEntries(); }
00180   TFndHLmd *GetLmdHit(Int_t hit_id)    { return ((TFndHLmd*) fLmdHits->At(hit_id)); }
00181   TFndHLmd *Find_Add_LmdHit(Int_t channel,Bool_t add_if_missing=kFALSE);
00182   
00183   TClonesArray *GetStbHits() { return fStbHits; }
00184   Int_t GetNumberOfStbHits() const { return fStbHits->GetEntries(); }
00185   TFndHStb *GetStbHit(Int_t hit_id)    { return ((TFndHStb*) fStbHits->At(hit_id)); }
00186   TFndHStb *Find_Add_StbHit(Int_t channel,Bool_t add_if_missing=kFALSE);
00187 
00188   void PrintHits(Int_t dpt_gts=0,Int_t dpt_tof=0,Int_t dpt_sil=0,Int_t dpt_lmd=0,Int_t dpt_stb=0); // Print Hits
00189 
00190   void PrintGts(Int_t depth = 0);
00191   void PrintTofHits(Int_t depth = 0);
00192   void PrintSilHits(Int_t depth = 0);
00193   void PrintSilClusters(Int_t depth = 0);
00194   void PrintLmdHits(Int_t depth = 0);
00195   void PrintStbHits(Int_t depth = 0);
00196 
00197   static TClonesArray *fgHTof;
00198   static TClonesArray *fgHSilCluster;
00199   static TClonesArray *fgHLmd;
00200   static TClonesArray *fgHStb;
00201 
00202   ClassDef(TFndHdt,2)   //  The "Hit Data Tape"
00203     // streaming version 2: Aug 29, 2007
00204     };
00205     
00206 #endif 

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