Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-05 08:14:39

0001 #ifndef __HCALUTIL_H__
0002 #define __HCALUTIL_H__
0003 //#include <TString.h>
0004 #include <list>
0005 #include <algorithm>
0006 
0007 #include <TROOT.h>
0008 #include <TFile.h>
0009 #include <TTree.h>
0010 #include <TGMsgBox.h>
0011 #include <TCanvas.h>
0012 #include <TGraph.h>
0013 #include <TString.h>
0014 #include <TText.h>
0015 #include <TApplication.h>
0016 #include <TStyle.h>
0017 #include <TSystem.h>
0018 #include <TGClient.h>
0019 #include <TGWindow.h>
0020 #include <TH1.h>
0021 #include <TH1F.h>
0022 #include <TH1D.h>
0023 #include <TProfile.h>
0024 #include <TF1.h>
0025 #include <TH2.h>
0026 #include <TH3.h>
0027 #include <TMath.h>
0028 #include <TSpectrum.h>
0029 #include "TVirtualFitter.h"
0030 #include <TSystemDirectory.h>
0031 #include <TSystemFile.h>
0032 
0033 class hcalUtil;
0034 class hLabHelper;
0035 class hcalHelper;
0036 class hcalTree;
0037 class tileHelper;
0038 class tileTree;
0039 class hcal;
0040 class stack;
0041 class tower;
0042 
0043 
0044 #include <hcalControls.h>
0045 
0046 // **************************************************************************
0047 
0048 extern "C" Double_t erfunc(Double_t *x, Double_t * par); 
0049 extern "C" Double_t erf_g(Double_t *x, Double_t * par);
0050 extern "C" Double_t powerFun(Double_t *x, Double_t * par);
0051 extern "C" Double_t power_g(Double_t *x, Double_t * par);
0052 extern "C" Double_t ps( Double_t *adc, Double_t *par);
0053 extern "C" Double_t sipmPeaks(Double_t *x, Double_t *par);
0054 extern "C" Int_t    sipmCalib(TString & hName, int mode=0);
0055 extern "C" Double_t AsymToX(Double_t asym);
0056 //extern "C" void     pcPattern(Int_t nx, Int_t ny, Int_t run=0, Int_t mode=1);
0057 extern "C" Double_t signalShape(Double_t *x, Double_t * par);
0058 //extern "C" void     fitShape(int chan);
0059 //extern "C" void     status();
0060 //extern "C" Int_t    evLoop(int run, int nevents=0, int nfiles=1);
0061 //extern "C" void     closeEvent();
0062 //extern "C" void     closeLoop();
0063 
0064 // **************************************************************************
0065 
0066 //#ifndef __CINT__
0067 //   ====================================================================================
0068   
0069 struct rootfile{
0070   rootfile(TString n, Int_t rn, TString rid) : name(n) ,runnumber(rn), runid(rid) {;}
0071   rootfile(const rootfile & last){
0072     this->name          = last.name;
0073     this->runnumber     = last.runnumber;
0074     this->runid         = last.runid;
0075   }  
0076   void print(){
0077     cout<<"<rootfile>  "<<name<<"  Run # "<<runnumber<<"  RunId  "<<runid<<endl;  
0078   }
0079   TString    name;
0080   Int_t      runnumber;
0081   TString    runid;
0082     
0083 };
0084 //  bool    operator()  runnumberequal(rootfile & rf, Int_t run) const {return run==rf.runnumber;}
0085 //   ====================================================================================
0086 
0087 struct prdffile{
0088   prdffile(TString n, Int_t rn, TString rid) : name(n) ,runnumber(rn), runid(rid) {;}
0089   prdffile(const prdffile & last){
0090     this->name          = last.name;
0091     this->runnumber     = last.runnumber;
0092     this->runid         = last.runid;
0093   }
0094   void print(){
0095     cout<<"<prdffile>  "<<name<<"  Run # "<<runnumber<<"  RunId  "<<runid<<endl;  
0096   }
0097   TString name;
0098   Int_t   runnumber;
0099   TString runid;
0100 };
0101 //  bool    operator()  runnumberequal(prdffile & pf, Int_t run) const {return run==pf.runnumber;}
0102 
0103 //   ====================================================================================
0104 
0105 class hLabHelper{
0106 
0107 protected:
0108   hLabHelper();
0109   virtual ~hLabHelper(){;}
0110   static   hLabHelper * single;
0111 
0112   
0113 public:
0114   static hLabHelper * getInstance(){if(!single) single = new hLabHelper(); return single;}
0115   static void         deleteInstance(){if(single) delete single;} 
0116 
0117   bool    evDisplay(Int_t run);
0118 
0119   void    getFileLists();
0120   void    decoderun(TString & fname, Int_t & rn, TString & rid);
0121   TFile * attachrootrun(Int_t rn);
0122   void    setRunKind(TString rK = "beam"); 
0123   Bool_t  setPRDFRun(int run, Bool_t bookH = kTRUE);
0124   Bool_t  setROOTRun(int run = 0);
0125   Int_t   runToRootFile(Int_t run = 0);
0126   Int_t   runToPRDFFile(Int_t run = 0);
0127   void    renameAndCloseRF();
0128   void    makeCanvasDirectory();
0129   void    updateMap();
0130   void    updateCalibration();
0131   void    initPRDFRun(Bool_t  bookH = kTRUE);
0132   void    fitShape(int chan, Double_t & peakVal, Int_t & peakPos, Int_t mode);
0133   void    getDetectorTiming();
0134   void    displaySumEvent();
0135   void    dofixes();      
0136   void    collect(Bool_t fitshape = kFALSE);
0137   Bool_t  reject();
0138 
0139   Int_t       runnumber;
0140   TString     runKind;
0141   Int_t       rfiles;
0142   TString     host;
0143   TString     rootTempFileName;
0144   TString     rootfName;
0145   TString     prdfName;
0146   TString     rootdirname;
0147   TString     cDirectory;         //  directory to store TCanvases for Run#
0148   list<rootfile>  roots;
0149   Int_t       pfiles;
0150   TString     prdfdirname;
0151   list<prdffile> prdfs;
0152   Int_t        eventseq;
0153   Int_t        eventsread;
0154 
0155   Int_t      * active;            //  list of active ADC channels  
0156   Float_t   ** adc; 
0157   Float_t    * pedestal;  
0158   Float_t    * rawPeak,    * rawTime;
0159 
0160   Double_t  ** fitResults;
0161   Float_t    * fitPeak,    * fitTime,    * fitInt,  * fitChi2;
0162   Float_t    * fitPeakRMS, * fitTimeRMS;
0163 
0164   Float_t    * calibPeak;    //  units of SiPM pixels
0165 
0166   Double_t  ** shapeD;
0167 
0168   TF1       ** shapes;
0169   TF1       ** sigFit;
0170   TF1       ** rvsc, **fmsc;                       //  Single cell calibration
0171   TGraph    ** gpulse;                             //  Graph of the pulse in indivuidual channel
0172   TH1       ** ft, ** fm, ** fw, ** fint, ** fpd, **fchi2;
0173   TH1      *** fitPar;                             //  Actual fit parameters in every channel
0174   TH1       ** rpeak, ** rtm;
0175   TH2        * rdata;
0176  
0177   //  Event produced by separately summing up all detector data in High and Low gains
0178   Double_t   * evtadcsum[2];
0179   Double_t   * evtfitpar[2];
0180   Double_t   evtpedestal[2];
0181   Double_t   evttime[2];
0182   Double_t   evtpeak[2];
0183   Double_t   tChi2[2];               //  Chi2 from signal fit of the total ampl sum
0184   TF1        * evtShape[2], * evtSignal[2];
0185   TGraph     * evtGraph[2];
0186   //
0187   TFile   * fhcl;
0188   TTree   * thcl;
0189 
0190 };
0191 
0192 //   ====================================================================================
0193 
0194 class hcalHelper{
0195 protected:
0196   hcalHelper();
0197   static hcalHelper * single;
0198   virtual ~hcalHelper(){ ; }
0199 
0200 public:
0201   static hcalHelper * getInstance(){if(!single) single = new hcalHelper(); return single;}
0202   static void         deleteInstance(){if(single) delete single;} 
0203   //  HCAL implementation for test beam
0204 
0205   hcal   * t1044;
0206   
0207   void     setCTriggerOn(Bool_t  ON = kTRUE);   //  program runs on cosmic data
0208   void     setCTriggerGRange(Int_t gain = 1);   //  Gain range used to trigger on cosmic
0209   void     setDisplayMode(Int_t mode = 3);      //  defult: show only summary
0210   void     setRunKind(TString rK = "beam"); 
0211   Int_t    evLoop(int run, int evToProcess=0, int fToProcess=1);
0212   Int_t    collectRaw();
0213   void     updateCalibration();
0214   void     hcalTrigger();
0215   void     hcalPattern(Int_t nx, Int_t ny, Int_t run, Int_t mod = 0);
0216   void     hcalImpact();
0217   void     fitHCalSignal();
0218   void     hcalDisplay();
0219   void     dofixes();
0220   Int_t    reject();
0221 
0222   Double_t     trThresholdBin;
0223   Double_t     twrThreshold;
0224   Double_t     stckSumThreshold;
0225 
0226   Int_t        runnumber;
0227   Int_t        eventseq;
0228   Int_t        eventsread;
0229   Int_t        displayMode;      //  amount and form of graphic data presented 
0230   Int_t        triggerOn;        //  if kFALSE - cosmic trigger is disabled  
0231   Int_t        triggerGain;      //  preamp range used for triggering if enabled
0232   Int_t        rejectRaw;
0233   Int_t        eventReject;
0234   Int_t        eventTrigger;
0235   Int_t        channels;
0236   Int_t        samples;
0237   Int_t        parameters;
0238   //  Energy sums from collectTileSummary()
0239   Double_t     uSum, cSum;
0240   Double_t     YF,  YU,   YC,   XU,    XC;
0241   Double_t     sumFU,      sumFC;
0242   Double_t     muxU, muxC, muxFU, muxFC;
0243   Int_t        muxUCh,     muxCCh,       muxUFiber,   muxCFiber;
0244 
0245   Int_t     ** adc;
0246   Int_t      * activeCh;
0247   //  processing run summaries
0248   TH2        * rdata;
0249 };
0250 
0251 //   ====================================================================================
0252 
0253   
0254 class hcal{
0255   hcal();
0256   ~hcal();
0257   friend class hcalHelper;
0258 public:
0259   //  currently number of stacks with reject codes
0260   Int_t     rejectEvent;   //  Event must be rejected 
0261   Bool_t    readyForEvent;
0262   Int_t     maxStacks;     //  may include scintillators between or upfront or what not
0263   Int_t     activeStacks;
0264   Int_t     activeCalStacks;
0265   Bool_t *  alive;
0266   Int_t  *  kinds;         //  for now is just StackId
0267   //  Stacks belong to hcal and towers belong to stacks 
0268   stack **  stacks;
0269   void      setCalibration();
0270   Int_t     getStackTiming();
0271   Int_t     update(Int_t displayMode = 3, Bool_t fitShapes=kFALSE);  //  returns reject 
0272   Int_t     collectTrPrimitives();
0273   void      displayRaw(Int_t mode = 0);
0274   void      displaySummary(Int_t mode = 0);
0275   void      clean();          //  clean all related objects for new event
0276   //  Summary
0277   Double_t  amplTotal;
0278   Double_t  eTotal;
0279   Double_t  calLCG;
0280   Double_t  scintLCG;
0281   TH1     * totalamp, * totale, * totallcg, * scintlcg; 
0282 };
0283 
0284 //   ====================================================================================
0285   
0286 class stack{
0287   friend class hcal;
0288   friend class hcalHelper;
0289 
0290 public:
0291 
0292   stack();
0293 
0294   stack(const Int_t kind, const Int_t chnls, const Int_t xch, const Int_t ych);
0295   ~stack();
0296   void  displayEvent(Int_t mode = 0);
0297   void  displayADCSum();
0298   void  displayTowerSummary(Int_t mode = 3);
0299   void  displayStackSummary(Int_t mode = 3);
0300   void  print();
0301   void  updateMap(Int_t stckloc);          //  Map Update in Towers is done Helper->HCal->Stack->Tower
0302   Int_t update(Bool_t fitShapes = kFALSE); //  EVent update. HCal, Stacks and Towers are updated from HCal
0303   Int_t getStackTime();
0304   Int_t getStackImpact(); 
0305   Int_t getStackTrack();//  returns reject code
0306   Int_t getTrigger();
0307   void  clean();          //  get ready for new event
0308 
0309   Int_t    reject;
0310   //   single energy scale calibration [GeV/ADC count [LG]) (copied into towers by setCalibration()). May became 
0311   //   different later
0312 
0313   Double_t stackECalib; 
0314   Int_t    triggerFlag;
0315   Int_t    triggerHits;
0316   Int_t    triggerSum;
0317   Int_t    eventsSeen;
0318   
0319   Int_t    stackId;      //   from enum )HINNER etc)
0320   Int_t    stackKind;    //   Stack kind (CALOR, COUNTER)
0321   Int_t    gains;        //   number of gain ranges
0322   Int_t    twrsInStack;  //   Maximum number of active towers in this stack
0323   Int_t    stackLoc;     //   first tower location in activeCh lookup table
0324   Int_t    nTwrsX;       //   Stack geometry in units of Towers
0325   Int_t    nTwrsY;       //   
0326   Int_t    key;          //   (stackId*10+gains)
0327   Bool_t   mapUpdated;
0328   Double_t totPed;
0329   Double_t totAmpl;      //   total sum of amplitudes in stack (inits LG)
0330   Double_t totCorAmpl;   //   fully corrected amplitude sum
0331   Double_t avTwrTime;
0332   Double_t rmsTwrTime;
0333   Double_t E;            //   Fully calibrated energy in Stack [GeV]
0334   Double_t xImpact;      //   x - Impact position in stack
0335   Double_t yImpact;      //   y - Impact position in stack
0336   tower ** towers;
0337  
0338   //  Event produced by separately summing up all detector data in High and Low gains
0339   Int_t        gainToUse;
0340   Int_t        twrsUsed[2];
0341   Double_t   * adcsum[2];
0342   Double_t   * fitPar[2];
0343   Double_t     fitPed[2];
0344   //  fit results for a total ADC sums (HIGH and LOW gains) in stack (exclude overflow towers)
0345   Double_t     fitTime[2];
0346   Double_t     fitPeak[2];
0347   Double_t     fitChi2[2];               //  Chi2 from signal fit of the total ampl sum
0348   TF1        * shape[2], * signal[2];
0349   TGraph     * graph[2];
0350   //  Muon Track in the stack
0351   //  counted towers with less then 3 samples in sat. region and above TWRAMPTHR
0352   Int_t        stackHits;
0353   Int_t        trackHits;
0354   Double_t     crossing, slope, trchi2, trackAmpl;
0355   //  Summaries
0356   TH1        * stFGR;
0357   TH1        * stFPed, * stFAmpl, * stFTime, * stChi2;
0358   TH1        * stSPed, * stSAmpl, * stSE,    * stAvT,  * stTRMS;
0359 
0360   TH2        * hitCG;
0361   //  cosmics summary
0362   TH1        * trAmp,  * trChi2,  * trCr,    * trSl;
0363   TH2        * trAmpCh2, * trAstH,* trASl,   * trATwr;
0364 
0365   //  saturation study
0366   TH1       *  satProb[2];  //  High and Low gains
0367    
0368 };
0369 
0370 //   ====================================================================================
0371     //  towers are created and updated by evloop in hcalHelper as readout objects, 
0372     //  converted into physics entities by stacks when added to stacks but still - 
0373     //  remain property of hcalHelper which updates them when new event is coming
0374   
0375 class tower{
0376   friend class hcalHelper;
0377 public:
0378   tower(){;}
0379   ~tower(){;}
0380   tower(Int_t stack, Int_t stkLoc, Int_t xSt, Int_t ySt);
0381   void  setChannel(Int_t channel, Int_t gain);
0382   Int_t update(Bool_t fitShape=kFALSE);  //   channel energies, times and gain selection in new event
0383   void  clean();           //   clean tower (we keep whole configuration stable, just update data)
0384   void  print();
0385   void  display();
0386 
0387   Int_t    reject;        //   for now just a signal of overflow in both (or single) ranges  
0388   Double_t twrECalib;     //   calibration coefficient (set by hcal->setCalibration()). Common to stack
0389   Double_t twrEScale;     //   equalization coefficient
0390   Int_t    stackId;       //   stack which owns this tower
0391   Int_t    index;         //   index in the stack y*HCALCOLUMNS + x  
0392   Int_t    key;           //   ((stackId*1000+index)*10)+gainToUse
0393   Int_t    x;
0394   Int_t    y;
0395   Int_t    gains;
0396   Int_t    gainToUse;
0397   Int_t    adcChannel[2]; //   location in activeCh[] and adc[][] storage areas (-stackLoc)
0398   Int_t    satFlag[2];
0399   Double_t rawPed[2];     //   2048 (PEDESTAL) subtructed
0400   Double_t rawAmpl[2], rawTime[2];
0401   Bool_t   attached;      //   attached to muon track when calibrating
0402 
0403   Double_t rped, rampl, rtime;   //  best raw values for amplitude and time (units LG)
0404   Double_t cped, campl, ctime;   //  mixed & corrected peds&Amplitude (in units of LG) and time
0405   Double_t E;                    //  fully calibrated energy in Tower [GeV]
0406   TF1        * shape[2], * signal[2];
0407   TGraph     * graph[2];
0408   // data accumulated since beginning of processing run
0409   TH1        * twrPed, * twrAmpl, * twrTime, * twrE;
0410 
0411   // Double_t     fitAmpl[2], fitTime[2];
0412 
0413 
0414 };
0415 
0416 //   ====================================================================================
0417 
0418 class hcalTree
0419 {
0420 
0421 protected:
0422   hcalTree();
0423   virtual ~hcalTree(){;}
0424   static   hcalTree * single;
0425 
0426 
0427 public:
0428   static hcalTree * getInstance(){if(!single) single = new hcalTree(); return single;}
0429   static void       deleteInstance(){if(single) delete single;} 
0430 
0431 
0432   //  switching output file if so required:   TBD
0433 
0434   void updateRootFile();
0435  
0436   int runnumber;
0437   int eventseq;
0438   int eventsread;
0439   int channels;
0440   int samples;
0441 
0442   //   1      overflows in calorimeter amplitudes
0443   //   10     tags outside range
0444   //   100    HCal time is unreliable
0445   //   1000   
0446   //   10000  Total energy in event is consistent with ZERO
0447   // 
0448   int rejectCode;
0449 
0450 };
0451 
0452 
0453 //   ====================================================================================
0454   
0455 class tileHelper{
0456 protected:
0457   tileHelper();
0458   static tileHelper * single;
0459   virtual ~tileHelper(){
0460     delete [] tileCalib;
0461     delete [] tileCalPeak;
0462   }
0463 
0464 
0465 public:
0466   static tileHelper * getInstance(){if(!single) single = new tileHelper(); return single;}
0467   static void         deleteInstance(){if(single) delete single;} 
0468 
0469   // **************************************************************************
0470   //  event data for a smartTile
0471 
0472   struct eventtilesummary{
0473     eventtilesummary(){
0474       evtGraph  = new TGraph(NSAMPLES);
0475       TString fitName  = "det adc sum";
0476       evtShape  = new TF1(fitName, &signalShape, 0., (Double_t)NSAMPLES, NPARAMETERS);
0477       fitName   = "det signal";
0478       evtSignal = new TF1(fitName, &signalShape, 0., (Double_t)NSAMPLES, NPARAMETERS);
0479     }
0480     Double_t    times[TILECHANNELS];
0481     Double_t    chi2[TILECHANNELS];
0482     Double_t    evtadcsum[NSAMPLES];
0483     Double_t    evtfitpar[NPARAMETERS];
0484     Double_t    evtpedestal;
0485     Double_t    evttime;
0486     Double_t    evtpeak;
0487     Double_t    tChi2;                   //  Chi2 from signal fit of the tile total amplitude
0488     Double_t    evtpc;                   //  event total pixel count (sum of calibrated counts in individual tile channels)
0489     Int_t       hitfiber;                //  fiber with highest signal
0490     Double_t    hitfiberpc;              //  pixel count in the hit fiber
0491     Double_t    hitfibertd;              //  time delta between hit fiber ends
0492     Double_t    yChi2;                   //  CHi2 from fitting Y coordinate in the tile
0493     Double_t    ySigma;
0494     TGraph    * evtGraph;
0495     TF1       * evtShape;
0496     TF1       * evtSignal;
0497     Int_t       rejectCode;
0498 
0499     void reset(){
0500       for (int is  = 0; is  < NSAMPLES;     is++)  evtadcsum[is] = 0.;
0501       for (int tch = 0; tch < TILECHANNELS; tch++) times[tch]    = 0.;
0502       evttime    = 0.;
0503       rejectCode = 0;
0504     }  
0505   };
0506 
0507   // **************************************************************************
0508   //  Run data for a smartTile
0509 
0510   struct runtilesummary{
0511     runtilesummary();
0512 
0513     // --------------------------------------------------------------------------
0514     //  Tile data (when calibrated - in units of fired cells)
0515     TH2     * rmax;     //  [TILECHANNELS][2050]; //  maximum uncalibrated amplitudes
0516     TH2     * rfsum;    //  [TILEFIBERS][2050];   //  raw fiber sum (only max fiber)
0517     TH2     * rtsum;    //  [TILEFIBERS][2050];   //  raw total sum (only max fiber)
0518     TH2     * rfasym;   //  [TILEFIBERS][-1:+1]   //  raw asymmetry per fiber
0519     TH1     * rtasym;   //  [-1 : +1]  right-left asymmetry  (using uncalibrated sums}
0520     TH1     * rx;       //  uncalibrated X
0521     TH1     * ry;       //  uncalibrated Y 
0522     TH2     * rimp;
0523     TH2     * cdata;    //  [TILECHANNELS][2000];  //  all calibrated data for further unalisis
0524     TH2     * cmax;     //  [TILECHANNELS][2000];  //  maximum calibrated amplitudes
0525     TH2     * cfsum;    //                         //  calobrated fiber sum
0526     TH2     * ctsum;    //  [TILECHANNELS][2000];  //  calobrated total sum
0527     TH2     * cfasym;   //  [TILEFIBERS][-1.-1.]   //  calibrated asymmetry per fiber
0528     TH1     * ctasym;   //  [-1 : +1]  right-left asymmetry (using calibrated sums)
0529     TH1     * cx;       //  calibrated X
0530     TH1     * cy;       //  calibrated Y 
0531     TH1     * fy;       //  fitted Y 
0532     TH2     * cimp;
0533     TH2     * cx_pc;    //  calibrated total asymmetry (X)  vs total pixel count
0534     TH2     * cy_pc;    //  calibrated weighted Y  vs total pixel count
0535     TH2     * fy_pc;    //  fitted Y  vs total pixel count
0536     TH2     * cimpW;    //  Weighted (by total pixel count) impact points 
0537 
0538     //  Trigger related
0539     TH1     * trhits;   //  Raw total sum with binning similar to "hits_tpc"
0540     TH2     * hits_tpc; //  Number of triggerable hits (above threshold) vs total pixel count
0541 
0542     // --------------------------------------------------------------------------
0543     //   accumulated in the processing phase and must be written to .root file
0544     TH3     * treff;    //  [HITMULTTHRESHOLDS][CHANNELTHRESHOLDS][0, 200];    //  total pixel count (histogramm) vs cuts on total number of hits and hit amplitude in individual channels
0545     TH3     * pc_imp;   //  total pixel count (histogramm) vs impact position
0546     TH2     * pc_pat;   //  fitted positions of maxiuma in pc_imp pixel distributions
0547     TH3     * pc_fimp;  //  total pixel count (histogramm) vs impact position (fitted Y)
0548     TH2     * pc_fpat;  //  fitted positions of maxiuma in pc_imp pixel distributions (fitted Y)
0549 
0550     // --------------------------------------------------------------------------
0551     //   debugging muon impact computations
0552     TH2        * XvsSl,    * XY;                 //  X value vs assumption about slope in the X vs Asymmetry 
0553     TH1        * Y0, * Y1, * Y2;        //  Parameters from the tile-Y fit
0554     TH2        * y_yChi2,  * s_y_Chi2;  // Y in the tile vs Chi2 of the Y fit and Tile signal Chi2 vs Chi2 of Y fit
0555     TH2        * y_ys,     * yc_rcode;
0556     TH1        * yCleaned, * yKept;
0557     TH1        * trcode;
0558 
0559     // --------------------------------------------------------------------------
0560     //   attempts on timing resolution in tiles and towers
0561     TH2        * td_r_l;            //  Time difference R/L vs total pixel count in the fiber
0562     TH3        * td_t_tw;           //  Time difference tile to tower vs tile pc and tower ampl
0563 
0564     
0565   };
0566 
0567   // **************************************************************************
0568 
0569   
0570   Int_t    evLoop(Int_t run, Int_t evToProcess, Int_t fToProcess);
0571   void     status();
0572   void     updateMap();
0573   void     updateCalibration();
0574   void     evreset();                 //  reset last event data
0575   void     tileTrigger();
0576   void     tileTiming();
0577   void     tileDisplay();
0578   void     tileTriggerDisplay();
0579   void     tilePattern(Int_t nx, Int_t ny, Int_t run, Int_t mod = 0);
0580   void     collectTileSummary();
0581   Double_t getYFit();
0582   void     tileImpact();
0583   void     fitTileSignal();
0584   Int_t    reject();
0585   eventtilesummary evtsum;
0586   runtilesummary   runsum;
0587   
0588   Int_t        channels;
0589   Int_t        samples;
0590   Int_t        fibers;
0591   Int_t        xdivisions,  ydivisions;
0592   Int_t        parameters;
0593   //  Energy sums from collectTileSummary()
0594   Double_t     uSum, cSum, luSum, lcSum, ruSum, rcSum;
0595   Double_t     YF,  YU,   YC,   XU,    XC;
0596   Double_t     sumFU,      sumFC;
0597   Double_t     muxU, muxC, muxFU, muxFC;
0598   int          muxUCh,     muxCCh,       muxUFiber,   muxCFiber;
0599   Double_t     ras,  cas,  rtas,  ctas;
0600   Double_t   * fiberY;
0601   Double_t   * fiberLY;         //  Calibrated Light Yields from individual fibers
0602   Double_t   * tileCalib;       //  Calibration coefficients for SiPM's currently in use (earlier measurements)
0603   Double_t   * tileCalPeak;     //  Fitted peak values scaled by tileCalib  (tile channels)
0604   int          hitcnt[CHANNELTHRESHOLDS]; 
0605 
0606   TCanvas    * fiberDisplay;
0607   TCanvas    * triggerDisplay;
0608   TCanvas    * impactDisplay;
0609   TCanvas    * lyPattern,  * lyFits;
0610   TF1        * yFit;
0611   TGraph     * fLY;
0612 
0613 };
0614 
0615 //   ====================================================================================
0616 
0617 
0618 class tileLightYield{
0619   tileLightYield();
0620   void  setrootfile(rootfile & rf){
0621     //    hcalHelper * hHelper = hcalHelper ::getInstance();
0622     rfile = new rootfile(rf);
0623   }
0624   void setdivisions(Int_t nx, Int_t ny){
0625     xdivisions  = nx;
0626     ydivisions  = ny;
0627     lightyield  = new Double_t * [ny];
0628     for(int iy =0; iy<ny; iy++) lightyield[iy] = new Double_t [nx];
0629       
0630   }
0631   rootfile   * rfile;
0632   Int_t        xdivisions, ydivisions;
0633   Double_t  ** lightyield;
0634 };
0635 
0636 //   ====================================================================================
0637 class tileTree
0638 {
0639 
0640 protected:
0641   tileTree();
0642   virtual ~tileTree(){;}
0643   static   tileTree * single;
0644 
0645 
0646 public:
0647   static tileTree * getInstance(){if(!single) single = new tileTree(); return single;}
0648   static void       deleteInstance(){if(single) delete single;} 
0649 
0650 
0651   //  switching output file if so required:   TBD
0652 
0653   void updateRootFile();
0654  
0655 
0656   //   1      overflows in calorimeter amplitudes
0657   //   10     tags outside range
0658   //   100    HCal time is unreliable
0659   //   1000   
0660   //   10000  Total energy in event is consistent with ZERO
0661   // 
0662   int rejectCode;
0663 };
0664 
0665 //   ====================================================================================
0666 
0667 class hcalUtil{
0668 protected:
0669   hcalUtil ();
0670   virtual ~hcalUtil(){;}
0671   static  hcalUtil * single;
0672 
0673 public:
0674   static hcalUtil * getInstance(){if(!single) single=new hcalUtil(); return single;}
0675   static void       deleteInstance(){if(single) delete single;} 
0676 
0677   Float_t xPeak(TF1* f, Float_t x1, Float_t x2);
0678 
0679   //  Float_t xPeak(TF1* f, Float_t x1, Float_t x2);
0680   Float_t width(TF1* f, Float_t x1, Float_t x2, Float_t peak);
0681 
0682   bool  shapeFit(TH1D * proj, Double_t * pE, Float_t & maxE, Double_t * pG, bool fine, bool MIP);
0683 
0684   bool  emcFit(TH1D * proj,  bool fine, bool sing, Double_t * pE, Float_t & maxE, Double_t * pG, bool MIP);
0685   bool  emcFit(TH1D * proj,  bool sing, Double_t * pE, Float_t & maxE, Double_t * pG);
0686   bool  emcFit(TH1D * proj,  bool sing, Double_t * pE, Float_t & maxE, Double_t * pG, Float_t minx, Float_t maxx);
0687   bool  twrMipFit(TH1D * proj,  Double_t * pE, Float_t & maxE, Double_t * pG);
0688   bool  twrTimeFit(TH1D * proj,  Double_t * pE, Float_t & maxE, Double_t * pG);
0689 
0690 };
0691 
0692 // hcalUtil    * hcalUtil    :: single = 0;
0693 // hLabHelper  * hLabHelper  :: single = 0;
0694 // hcalHelper  * hcalHelper  :: single = 0;
0695 // hcalTree    * hcalTree    :: single = 0;
0696 // tileHelper  * tileHelper  :: single = 0;
0697 // tileTree    * tileTree    :: single = 0;
0698 
0699 
0700 //#endif   //  CINT
0701   
0702 #endif   //  HCALUTIL_H_
0703