// Author: Andrew M. Rogers and Mark Wallace, NSCL 07/01/2006
//* Copyright (C) 2006-2008 Andrew M. Rogers and Mark Wallace

#ifndef __TMCP_H
#define __TMCP_H

#include <iostream>

#ifndef  __ROOTDEFINE_H
#define  __ROOTDEFINE_H
#include "rootDefine.h"
#endif
#ifndef  __PACKETID_H
#define  __PACKETID_H
#include "packetID.h"
#endif

#include <TRandom3.h>
#include <TROOT.h>
#include <TBranch.h>
#include <TTree.h>
#include <TObject.h>
#include <TFolder.h>

#include "TMcpDet.h"


using namespace std;


class TMcp : public TObject {
 private:
  TRandom3     fRandom;                       //! The class's random number generator.  

  Int_t        fQdcSlot[TMCP_NQDCS];          //!

 protected:
  TString      fName;                         //! Object identifer.
  TString      fTitle;                        //! Object title.

  Char_t       *mcpMapFile;                   //! MCP corner and time map file.
  
 public:
  TMcp        *fCon;                          //!
  Bool_t       fAddRndm;                      //! Add random number to convert from short data types to double.

  UShort_t     fNwords;                       // Number of words in an MCP packet.
  UShort_t     time[32];                      // Raw TDC times.
  UShort_t     charge[TMCP_NQDCS][32];        // Raw QDC charge.
  UShort_t     ene[32];                       // Raw ADC energy.

  Double_t     rTime[32];                     // Relative time.
  Double_t     timeCorr[32];                  // Corrected time.
  Double_t     maskX;                         // Mask x-position in mm.
  Double_t     maskY;                         // Mask y-position in mm.
  Double_t     xAngle;                        // 
  Double_t     yAngle;                        //
  Double_t     iAngle;                        // Incident angle. 

  Double_t     tShift[4];                     //!
  Double_t     thetaMCP[2];                   //!
  Double_t     tarMcpPlasticGap;              //!
  Double_t     mcpMcpGap;                     //! MCP0 to MCP1 distance.
  Double_t     upMcpPlasticGap;               //!
  Double_t     maskTarGap;                    //! 

  TMcpDet      mcp0;                          //  MCP0 (Upstream MCP).
  TMcpDet      mcp1;                          //  MCP1 (Target MCP).

  TBranch      *b_time;                       //! Raw TDC times branch.
  TBranch      *b_charge;                     //! Raw QDC charge branch.
  TBranch      *b_ene;                        //! Raw ADC energy.
  TBranch      *b_rTime;                      //! Relative time.
  TBranch      *b_timeCorr;                   //! Corrected time.
  TBranch      *b_maskX;                      //! Mask x-position in mm.
  TBranch      *b_maskY;                      //! Mask y-position in mm.
  TBranch      *b_xAngle;                     //! 
  TBranch      *b_yAngle;                     //!
  TBranch      *b_iAngle;                     //!

  TBranch      *b_mcp0;                       //! MCP0 Branch.
  TBranch      *b_mcp1;                       //! MCP1 Branch.

  TFolder      *f_mcp0;                       //!
  TFolder      *f_mcp1;                       //!

  TTree        *fChain;                       //! pointer to the analyzed TTree or TChain
  Int_t        fCurrent;                      //! current Tree number in a TChain

 public:
  TMcp(): fName(), fTitle() {fRandom.SetSeed(0);}
  ~TMcp() {}
  TMcp(const TMcp &);                                                   // The copy ctor

  const Char_t *GetName() const {return fName;}
  const Char_t *GetTitle() const {return fTitle;}
  void          SetName(const Char_t *name);
  void          SetNameTitle(const Char_t *name, const Char_t *title);
  void          SetTitle(const Char_t *title=""); 

  Int_t         Calibrate(Option_t *prefix="",Option_t *path="",
			  Option_t *treeName="",
			  Option_t *option="RECREATE");                  // Calibrate detectors.
  Int_t         Calculate(Long64_t);                                     // Calculate quantities.
  void          Clear(Option_t *option="");                              //
  void          Copy(TObject &mcp) const;                                // Copy method.
  void          CreateFolders();                                         // 
  Int_t         GenPrime(Option_t *prefix="",Option_t *path="",
			 Option_t *treeName="",
			 Option_t *option="RECREATE");                   // Generate primary data.
  Int_t         GenPrime(Long64_t entry);                                // Generate primary data for an entry.
  void          InitBranch(TTree *tree,Option_t *stage);                 // Initialize the branch structure of the tree.
  void          InitClass();                                             //
  void          InitTree(TTree *tree);                                   // Initialize the tree.
  Bool_t        LoadQdcTdcMap();                                         // Load the MCP map file.
  Bool_t        SetMcpMapFile(Char_t *filePath);                         // Location of the MCP corner and time map file.

  Bool_t        Unpack(UShort_t *pEvent);      // Unpack MCP data from buffer.
  UShort_t*     UnpackEnergy(UShort_t *p);     // Unpack the MCP ADC data from buffer.
  UShort_t*     UnpackTime(UShort_t *p);       // Unpack the MCP TDC data from buffer.
  UShort_t*     UnpackCharge(UShort_t *p);     // Unpack the MCP QDC data from buffer.

  
  ClassDef(TMcp,4)     // MCP Tracking System Class.
};

#endif

Last change: Sun Dec 21 12:38:49 2008
Last generated: 2008-12-21 12:38

This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.