Makefile et classe perso

cs_jeje42 Messages postés 3 Date d'inscription jeudi 2 avril 2009 Statut Membre Dernière intervention 4 avril 2009 - 2 avril 2009 à 22:28
cs_jeje42 Messages postés 3 Date d'inscription jeudi 2 avril 2009 Statut Membre Dernière intervention 4 avril 2009 - 4 avril 2009 à 22:32
Bonjour a toutes et a tous,



Je suis assez novice en C++ et j'aurai besoin d'aide si cela est possible.


J'utilise un framework specifique a une collab de physique appliquee,
et je suis en train de creer ma propre classe pour l'inclure dans mon
analyse. Le probleme c'est qu'a la compilation, ma classe n'est pas
interpretee, je me demande si je dois en faire une librairie et si oui,
comment creer cette librairie.


Pour info, j'utilise un Makefile pour compiler le code et le logiciel
utilise en sortie pour afficher le resultat (arbres, histogrammes, etc)
est ROOT.


En vous remerciant,


Jerome



ps1 : voici mon message d'erreur :


g++ -O Muonjj.o ana.o
-L/d0usr/products/prd/root/Linux-2-4/v4_04_02b_fbits_eh+GCC_3_4_3_+opt/lib
-lCore -lCint -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript
-lMatrix -lPhysics -lGui -pthread -lm -ldl -rdynamic -L
/home/jammes/MAKE_HISTOS/libraries -lmet_util -ltmb_tree -o ana


Muonjj.o: In function `__static_initialization_and_destruction_0(int, int)':


Muonjj.o(.text+0x43e): undefined reference to `ROOT::GenerateInitInstance(Muonjj const*)'


Muonjj.o(.gnu.linkonce.d._ZTV6Muonjj+0xe4): undefined reference to `Muonjj::ShowMembers(TMemberInspector&, char*)'


Muonjj.o(.gnu.linkonce.d._ZTV6Muonjj+0xe8): undefined reference to `Muonjj::Streamer(TBuffer&)'


Muonjj.o: In function `Muonjj::IsA() const':


Muonjj.o(.gnu.linkonce.t._ZNK6Muonjj3IsAEv+0x13): undefined reference to `Muonjj::Class()'


collect2: ld returned 1 exit status


make: *** [ana] Erreur 1



ps2 : Muonjj est le nom de la classe perso, ana.cxx le nom du programme principal.

Code muonjj.h :
 
#ifndef MUONJJ_H
#define MUONJJ_H
 
#include "tmb_tree/TMBLorentzVector.hpp"
#include "TLorentzVector.h"
#include "TVector3.h"
 
 
class Muonjj : public TLorentzVector
{
 
protected :
 
Double_t fE_Muonjj; //definit ici l'energie du vecteur de lorentz pour le muon
TVector3 fP_Muonjj; //definit le 3-vecteur des impulsions pour le muon
 
public :
 
Muonjj(void);
Muonjj(const Muonjj &muon_copie);
~Muonjj(void);
 
//pour l'instant on ne donne aucune methode propre a la classe Muonjj
 
ClassDef(Muonjj,5);
};
 
 
#endif

Code muonjj.cpp :
 
#include
#include "Muonjj.h"
#include "TObject.h"
#include "TClonesArray.h"
#include "TLorentzVector.h"
 
ClassImp(Muonjj)
 
 
 
 
//constructeur de classe herite du constructeur de la mere (TLorentzVector)
 
Muonjj::Muonjj(void) : TLorentzVector(0.,0.,0.,0.)
{
printf("Execution du constructeur de la classe Muonjj");
return;
}
 
 
//constructeur de copie a partir des variables de la classe Muonjj et des methodes heritees de TLorentzVector
 
Muonjj::Muonjj(const Muonjj & muon_copie) : TLorentzVector(muon_copie)
, fP_Muonjj(muon_copie.Vect()), fE_Muonjj(muon_copie.T()){}
 
 
//{
// fP_Muonjj.X() = muon_copie.X();
// fP_Muonjj.Y() = muon_copie.Y();
// fP_Muonjj.Z() = muon_copie.Z();
// fE_Muonjj = muon_copie.T();
//}
 
 
//destructeur de la classe Muonjj
Muonjj::~Muonjj(void)
{
printf("Execution du destructeur de la classe Muonjj");
return;
}
 
 
 

Code ana.cxx :
 
#include
#include <sstream>
#include <fstream>
#include <vector>
 
//#include <map>
// ROOT includes :
#include <TROOT.h>
#include "TCanvas.h"
#include "TApplication.h"
#include "TPad.h"
#include "TGraphErrors.h"
#include "TH1.h"
#include "TFile.h"
#include "TTree.h"
#include "TFriendElement.h"
#include "TMath.h"
#include "TRandom.h"
#include "TLeaf.h"
 
 
#include "tmb_tree/TMBVector3.hpp"
#include "tmb_tree/TMBMuon.hpp"
#include "tmb_tree/TMBMCpart.hpp"
#include "tmb_tree/TMBLorentzVector.hpp"
#include "tmb_tree/TMBTau.hpp"
#include "tmb_tree/TMBJet.hpp"
#include "tmb_tree/TMBMCvtx.hpp"
 
 
#include "Muonjj.h"
 
//Muonjj* Muonc = new Muonjj;
//Muonjj* LooseMuonc = new Muonjj;
 
int main(int argc, char *argv[])
{
bool debug=false;
if(debug)
{
std::cout << "argc = " << argc << std::endl;
}
TApplication theApp("App", &argc, argv);
 
 
const std::string rootfile1="example_file_W_jets.root";
const std::string rootfile2="MUinclusive_0_Skim.root";
 
TFile *tfileSI = TFile::Open(rootfile2.c_str());
TTree* ch = (TTree*)tfileSI->Get("TMBTree");
const Long64_t nentries=ch->GetEntries();
 
 
TFile* hfile = new TFile("tmbtree_to_tree.root","RECREATE");
 
 
 
double Muon_Pt=-1.;
double Muon_Eta=-100.;
// double Muon_calEta=-100.;
double LooseMuon_Pt=-1.;
double LooseMuon_Eta=-100.;
// double LooseMuon_calEta=-100.;
 
//Muonjj* Mu;
//Mu = new Muonjj;
 
 
 
TTree *outputTree = new TTree("mycopy","copy from TMBTree");
 
 
 
if(nentries != 0){
 
 
TClonesArray* p20Muon = new TClonesArray("Muonjj",10);
TClonesArray* p20LooseMuon = new TClonesArray("Muonjj",10);
 
TBranch *b_muon=ch->GetBranch("Muon");
TBranch *b_loosemuon=ch->GetBranch("LooseMuon");
 
 
ch->SetBranchAddress("Muon", &p20Muon);
ch->SetBranchAddress("LooseMuon", &p20LooseMuon);
 
 
outputTree->Branch("Muonjj",&p20Muon);
 
 
//outputTree->Branch("LooseMuon", &p20LooseMuon,"",2);
 
//TLeaf *l_muon_calEta=b_muon->GetLeaf("Muon/Muon._calEta");
 
 
outputTree->Branch("LooseMuonjj",&p20LooseMuon);
 
 
 
 
for(Long64_t evtc=0;evtc<nentries;++evtc)
{
 
Long64_t localentry = ch->LoadTree(evtc);
b_muon->GetEntry(localentry);
b_loosemuon->GetEntry(localentry);
 
 
Int_t nmuons=p20Muon->GetLast()+1;
 
if(nmuons>=1)
{
for(int muonc=0;muonc<nmuons;++muonc)
{
 
Muonjj* Muonc=static_cast<Muonjj*>(p20Muon->At(muonc));
 
Muon_Pt=(*Muonc).Pt();
Muon_Eta=(*Muonc).Eta();
// Muon_calEta=(*Muonc).calEta();
 
}
}
 
 
 
Int_t nloosemuons=p20LooseMuon->GetLast()+1;
 
if(nloosemuons>=1)
{
for(int loosemuonc=0;loosemuonc<nloosemuons;++loosemuonc)
{
 
Muonjj* LooseMuonc=static_cast<Muonjj*>(p20LooseMuon->At(loosemuonc));
 
 
LooseMuon_Pt=(*LooseMuonc).Pt();
LooseMuon_Eta=(*LooseMuonc).Eta();
// LooseMuon_calEta=(*LooseMuonc).calEta();
 
 
 
}
}
 
 
 
outputTree->Fill();
}
outputTree->GetCurrentFile()->Write();
}
 
 
 
 
 
outputTree->Print();
 
 
delete hfile;
 
//delete Muonc;
//delete LooseMuonc;
 
theApp.Run("kTRUE");
 
return0;
 
}
 

Code Makefile :
 
ARCH = linux
 CXX ObjSuf o
SrcSuf = cxxExeSuf DllSuf so
OutPutOpt = -o
 
VPATH=../src
 
ROOTCFLAGS := $(shell root-config --cflags)
ROOTLIBS := $(shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)
 
ifeq ($(ARCH),linux)
# Linux with egcs, gcc 2.9x, gcc 3.x (>= RedHat 5.2)
CXX = g++
CXXFLAGS = -O -Wall -fPIC
LD = g++
LDFLAGS = -O
SOFLAGS = -shared
endif
 
 
 
ifeq ($(ARCH),linuxkcc)
# Linux with the KAI compiler
CXX = KCC --one_instantiation_per_object
CXXFLAGS = -fPIC +K0
LD = KCC
LDFLAGS = -O $(shell root-config --cflags)
SOFLAGS =
endif
 
 
 
#CXXFLAGS += $(ROOTCFLAGS) -I/d0dist/dist/releases/p14.05.01/include
#LIBS = $(ROOTLIBS) $(SYSLIBS) -L../TMBTree_so_KCC_4_0_v3_05_00b -lTMBTreeClasses_C
#GLIBS = $(ROOTGLIBS) $(SYSLIBS) -L./TMBTree_so_KCC_4_0_v3_05_00b -lTMBTreeClasses_C
 
#CXXFLAGS += $(ROOTCFLAGS) -I/users_common/pgris/LIB/myinclude -I/opt/gcc-3.2.3/include/c++/3.2.3 -I/d0dist/dist/releases/p14.05.01/include
CXXFLAGS += $(ROOTCFLAGS) -I/home/jammes/MAKE_HISTOS/libraries -I/home/jammes/MAKE_HISTOS/tmb_tree/tmb_tree -I/home/jammes/MAKE_HISTOS/met_util/met_util -I/home/jammes/MAKE_HISTOS/tmb_tree -I/home/jammes/MAKE_HISTOS/cafe
-I/home/jammes/MAKE_HISTOS/cafe/cafe
#LIBS = $(ROOTLIBS) $(SYSLIBS) -L /users_common/pgris/LIB/TMBTree_so_KCC_4_0_v3_05_00b -lTMBTreeClasses_C
#GLIBS = $(ROOTGLIBS) $(SYSLIBS) -L /users_common/pgris/LIB/TMBTree_so_KCC_4_0_v3_05_00b -lTMBTreeClasses_C
LIBS = $(ROOTLIBS) $(SYSLIBS) -L /home/jammes/MAKE_HISTOS/libraries -lmet_util -ltmb_tree
GLIBS = $(ROOTGLIBS) $(SYSLIBS) -L /home/jammes/MAKE_HISTOS/libraries -lmet_util -ltmb_tree
 
 
 
MUONJJO = Muonjj.$(ObjSuf)
MUONJJS = Muonjj.$(SrcSuf)
MUONJJ = Muonjj$(ExeSuf)
 
 
anaO = ana.$(ObjSuf)
anaS = ana.$(SrcSuf)
ana = ana$(ExeSuf)
 
 
 
$(ana) : $(MUONJJO) $(anaO)
$(LD) $(LDFLAGS) $^ $(GLIBS) $(OutPutOpt)$@
@echo "$@ done"
clean:
@rm -f *.$(OBJS) core
.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
 
.$(SrcSuf).$(ObjSuf):
$(CXX) $(CXXFLAGS) -c $<
 
 
 


Jerome

3 réponses

fregolo52 Messages postés 1114 Date d'inscription mercredi 15 juin 2011 Statut Membre Dernière intervention 6 mai 2021 4
3 avril 2009 à 09:13
dur dur !

- Muonjj.o(.text+0x43e): undefined reference to `ROOT::GenerateInitInstance(Muonjj const*)'
  Je vois pas comment une ROOT peut connaître ta classe Muonjj, à moins que le prototype de cette fonction soit : ROOT::GenerateInitInstance(TLorentzVector const*)

Les fonctions introuvable sont héritées ?

je ne vois pas les fonctions :
Muonjj.o: In function `__static_initialization_and_destruction_0(int, int)'
Muonjj.o: In function `Muonjj::IsA() const'
0
cs_jeje42 Messages postés 3 Date d'inscription jeudi 2 avril 2009 Statut Membre Dernière intervention 4 avril 2009
3 avril 2009 à 22:25
Oui, en fait je pense que root verifie si les classes ont ete
correctement ecrites c'est pour ca qu'il a pris comme argument ma
classe.  A mon avis, Root ne comprend pas mom(mes) constructeur(s)
et/ou mon destructeur.

En effet, avant, le code qui marchait bien avait a la place de Muonjj,
ma classe perso, une classe incluse dans un package existant dans le
framework de la collaboration, appelee la classe "TMBMuon", situee dans
le package tmb_tree, dont voici le code :


##### TMBMuon.hpp #####


#ifndef TMBMuon_H

#define TMBMuon_H


//////////////////////////////////////////////////////////////////////////

//                                                                     
//

// TMBTree Muon
class                                                  
//

//                                                                     
//

//////////////////////////////////////////////////////////////////////////


// Constants for smearing

#define    I_par_A_TMBMuon  0

#define    I_par_B_TMBMuon  4

#define    I_par_Bpt_TMBMuon  8

#define    I_scale_TMBMuon  12

#define    I_smt_ncft_cut_TMBMuon 16

#define    I_smt_eta_cut_TMBMuon  17

#define    I_smt_eta_cft_cut_TMBMuon  18

#define    I_nosmt_ncft_cut_TMBMuon 19

#define    I_nosmt_eta_cut_TMBMuon  20

#define    I_nosmt_eta_cft_cut_TMBMuon  21

#define    npar_TMBMuon  22


#include "tmb_tree/TMBLorentzVector.hpp"

#include "tmb_tree/TMBMuonType.hpp"

#include "tmb_tree/TMBTrack.hpp"

#include <string>


#ifndef ROOT_TRef

#include "TRef.h"

#endif

#ifndef ROOT_TRefArray

#include "TRefArray.h"

#endif


class TMBTrack;

class TMBVertex;


/**

 * Reconstructed Muon information and  usefull functions such as \ref TMBMUON_smear

 * \ingroup reco

 */

class TMBMuon : public TMBLorentzVector {


public:


  /// which kind of muon types is the best measurement we have?

  enum Type {

    kLocalCorr   = 0,

    kCentralCorr = 1,

    kSmearedMC   = 2

  };


private:


  // different muon types

  TMBMuonType _local;      ///< local
muon parameters measured in the muon chambers (no calorimeter eloss
correction)

  TMBMuonType _localcorr;  ///< local muon parameters measured in the muon chambers w/ calorimeter eloss correction

  TMBMuonType _central;    ///< muon parameters from its matched central track

  TMBMuonType _centralcorr;///< muon parameters from its matched central track w/ CFT only track correction

  TMBMuonType _global;     ///< global muon
parameters from the global fit between local and central parameters

  TMBMuonType _smearedMC;  ///< MC smeared muon parameters

  Type _best; ///< which kind of muon types is the best measurement we have


  // muon system info:

  Int_t        _nhit; 
       ///< number of hits in the muon
chambers,  defined as (nwhitA+10*nwhitBC+1000*nshitA+10000*nshitBC)

  Int_t       
_ndeck;     ///< Matching decks, defined as
(nwdeckA+10*nwdeckBC+1000*nsdeckA+10000*nsdeckBC)

  Int_t       
_region;    ///< region in the muon system (0:
central, 1: forward z<0, 2: forward z>0)

  Int_t       
_octant;    ///< octant in the muon system (from 0 to
7 starting at phi=0)

  Float_t      _chisqloc;  ///< Chisquare from local muon chamber fitting

  Float_t      _sctimeA;   ///< Scintillator time for A-segment

  Float_t      _sctimeB;   ///< Scintillator time for B-segment

  Float_t      _sctimeC;   ///< Scintillator time for C-segment

  Float_t     
_xA;        ///< x coordinate of
center point of A-segment (x local position)

  Float_t     
_yA;        ///< y coordinate of
center point of A-segment (y local position)

  Float_t     
_zA;        ///< z coordinate of
center point of A-segment (z local position)

  Float_t     
_bdl;       ///< B dl of the muon
through the toroid (not filled yet)


  // matching info:

  Int_t       
_nseg;        ///< Matching
segments (0: no segments; MTC or hit) (1:A layer; 2:BC; 3:A+BC;
negativ: w/o central track)

  Int_t       
_ndof;         ///< Number of
degree of freedom of the global muon fit

  Float_t     
_deltaPhi;    ///< delta_phi between A layer segment
and the matching charged particle (straight line extrapolation)

  Float_t     
_deltaEta;    ///< delta_eta between A layer segment
and the matching charged particle (straight line extrapolation)

  Float_t      _deltaDrift;  ///<
distance between A layer segment and the matching charged particle
(straight line extrapolation)

  Float_t     
_chisq;       ///< Chisquare from
global matching (global muon fit)

  Float_t     
_zAtPca;      ///< z coordinate at Pca (cm)
(if matched muon)

  Float_t     
_impPar;      ///< Impact parameter in xy
plane (cm) (if matched muon)

  Float_t      _impParSig;  
///< Muonid impact parameter significance (if matched muon)

  Float_t      _err_impPar;  ///< Error of impact parameter (if matched muon)

  Float_t      _err_zAtPca;  ///< Error of z coordinate at Pca (if matched muon)

  Float_t     
_dca;         ///< dca of
the track associated with the muon (0 if unmatched)

  Float_t     
_deteta;      ///< Muon detector eta at the
A-layer (R=292.059cm)

  TRef        
_chptr;       ///< Link to the
corresponding charged particle object (if matched muon)

  TRef        
_vtxref;      ///< Link to the
corresponding vertex object (if matched muon)


  // MTC info:

  Int_t       
_calnLayer;   ///< Number of layers contribution to the
muon signal found by the MTC algorithm

  Int_t       
_nmtc;        ///< Muon track in
calorimeter (MTC): -1 not done, 0 not found, 1 found

  Float_t      _etrack_best; ///< Energy in cal cells associated with the matching MTC track

  Float_t     
_caleSig;     ///< Significance of the energy
reconstructed by the MTC algorithm

  Float_t     
_calEta;      ///< Rapidity of the muon
signal found by the MTC algorithm

  Float_t     
_calPhi;      ///< Azimuthal angle of the
muon signal found by the MTC algorithm

  Float_t     
_eloss;       ///< Estimation of the
muon energy loss in the calorimeter (Run I estimation)


  // isolation variables

  Int_t       
_nTrk5;     ///< Total number of tracks in a
cone of radius 0.5 centered around the muon

  Float_t      _EInCone1;  ///< Energy in a dR=0.1 cone around the muon

  Float_t      _EInCone15; ///< Energy in a dR=0.15 cone around the muon

  Float_t      _EInCone2;  ///< Energy in a dR=0.2 cone around the muon

  Float_t      _EInCone4;  ///< Energy in a dR=0.4 cone around the muon

  Float_t      _EInCone6;  ///< Energy in a dR=0.6 cone around the muon

  Float_t      _drJet5;   
///< Distance (R) from the nearest jet reconstructed with the Run II
cone algorithm (0.5 cone radius)

  Float_t      _etTrkCone5;///< Total
transverse momentum of tracks in a cone of radius 0.5 centered around
the muon

  Float_t      _etHalo;   
///< Total transverse energy measured in the calorimeter in the
anulus between 0.1 and 0.4 centered around the muon track


  // Flags

  Int_t _isLoose;     ///< Flag indicating whether the muon passes the loose identification criteria

  Int_t _isMedium;    ///< Flag indicating whether the muon passes the medium identification criteria

  Int_t _isTight;     ///< Flag indicating whether the muon passes the tight identification criteria

  Int_t _hasLocal;    ///< Flag indicating whether the muon momentum was measured in the muon system

  Int_t _hasCentral;  ///< Flag indicating whether the muon is matched to a central track

  Int_t _hasCal;      ///< Flag
indicating whether the muon was identified as a MIP in the calorimeter
(MTC algorithm)

  Int_t _isMuonEventOK;///< Flag indicating whether the muon event is OK (Xing error, crate error, ...)

  Int_t _isCosmic;     ///< Flag indicating whether the muon passes timing cuts for cosmic removal

  Int_t _isCosmicT;    ///< Flag indicating
whether the muon passes timing and dca cuts for cosmic removal

 

  // Expected number of hits

  Int_t _expWhitsA;  ///< Expected number of wire hits in the A layer (not implemented in the thumbnail yet)

  Int_t _expWhitsBC; ///< Expected number of wire hits in the BC layer (not implemented in the thumbnail yet)

  Int_t _expShitsA;  ///< Expected number of scintillator
hits in the A layer (not implemented in the thumbnail yet)

  Int_t _expShitsBC; ///< Expected number of scintillator hits in the BC layer (not implemented in the thumbnail yet)


  Float_t _rand; ///< random number  used in MC smearing


public:


  /// Default constructor

  TMBMuon();


  /// Initializing constructor

  TMBMuon(Double_t pT, Double_t eta, Double_t phi, Type best,

      const TMBMuonType& local,   const TMBMuonType& localcorr,

      const TMBMuonType& central, const TMBMuonType& centralcorr,

      const TMBMuonType& global,  const TMBMuonType& smearedMC);

           

  /// Local muon system info setter

  void SetLocalInfo(Int_t nhit, Int_t ndeck, Int_t region, Int_t octant,

        Float_t chisqloc, Float_t sctimeA, Float_t sctimeB, Float_t sctimeC,

        Float_t xA, Float_t yA, Float_t zA, Float_t bdl);


  /// matching info setter

  void SetMatchingInfo(Int_t nseg, Int_t ndof,

        Float_t deltaPhi, Float_t deltaEta, Float_t deltaDrift,

        Float_t chisq, Float_t zAtPca, Float_t impPar, Float_t impParSig,

        Float_t err_zAtPca, Float_t err_impPar, Float_t dca,

        TRef chptr, TRef vtxref);


  /// set detector eta

  void SetDetEta(Float_t deteta);


  /// MTC info setter

  void SetMTCInfo(Int_t nmtc, Int_t calnLayer, Float_t etrack_best,

        Float_t caleSig, Float_t calEta, Float_t calPhi, Float_t eloss);


  /// Isolation info setter

  void SetIsolationInfo(Int_t nTrk5, Float_t EInCone1, Float_t EInCone15, Float_t EInCone2,

        Float_t EInCone4, Float_t EInCone6,

        Float_t drJet5, Float_t etTrkCone5, Float_t etHalo);


  /// Flags setter

  void SetFlags(Int_t isLoose, Int_t isMedium, Int_t isTight,

        Int_t hasLocal, Int_t hasCentral, Int_t hasCal,

        Int_t isMuonEventOK, Int_t isCosmic, Int_t isCosmicT);


  /// Expected number of hits setter

  void SetExpectedHits(Int_t expWhitsA, Int_t expWhitsBC, Int_t expShitsA, Int_t expShitsBC);


  /// MC smearing random number setter

  void SetMCsmearingRand(Float_t rand);


  /// Correct Muon pT based on dca - Overwrites _centralcorr

  void CorrectPt(double dca);

  /// \defgroup  TMBMUON_smear  Muon momentum smearing in CAFTree

  /// The muon momentum can be smeared within CAF using a set of functions:

  /// two functions with predefined smearing parameters, and one function with user-defined inputs

  /*! \addtogroup  TMBMUON_smear

*

*  @{

*  There are three methods in TMBMuon to smear muon momentum:

*  \code

*   void ActAsSmeared(Float_t * par, string name);

*   void ActAsSmeard_pre();

*   void ActAsSmeard_post();

*  \endcode

*  The methods will overwrite the values returned

*  by SmearedMC() and the momentum stored in

*  TMBMuon (returned by Pt() ) with the new smeared

*  values and will set the _best flag to kSmearedMC.

*  \code

*  ActAsSmeard(Float_t * par, string name)

*  The array par controls the smearing as described below.



*  ActAsSmeard_pre()

*  The smearing parameters are preset to be identical to

*  the RPC parameters in D0Correct and are optimised to describe

*  Data with run<2e5 (p17 old smearing parameters)

*

*  ActAsSmeard_post()

*  The smearing parameters are preset to describe

*  Data with run>2e5 (p17 old smearing parameters)

*  \endcode

*

*  The muons are smeared and scaled by a pt dependent

*  Gaussian in q/pt either with:

* \code

*  q/pt ->  S*q/pt + (A+B/pt)*rndnum

*  \endcode

*  or with:

* \code

*  q/pt ->  q/pt + sqrt(A^2+B^2*cosh(eta_cft)/pt^2)*rndnum

*  \endcode

*  if the name passed into ActAsSmeared contains the string "zjpsi" [default] (cf. D0Note 5449)

*  Where rndnum=MCsmearingRand(); is the Gaussian random

*  number already stored in TMBMuon.

*  (If needed it can be set with TMBMuon::SetMCsmearingRand(ran) ).



*  The Parameters S,A,B are set separately in 4 regions



*  region             offset

*  ----------------------------

*  SMT,Central           0

*  SMT,Forward           1

*  noSMT,Central         2

*  noSMT,Forward         3




*  where SMT means that the track has >0 SMT hits

*  and  Forward means that that the Eta() and number

*  of CFT hits are satisfying:

*  fabs(Muon.Eta() ) >  eta_cut || numCFTHits <  ncft_cut

*

*  Where eta_cut and ncft_cut are set by

*  the parameter array separately for SMT and noSMT,

*  (defaults are eta_cut=1.6 ncft_cut=0).

*

*  SMT:

*  eta_cut=par[13];

*  ncft_cut=par[12];

*  noSMT:

*  eta_cut=par[15];

*  ncft_cut=par[14];




*

*  The parameters S,A,B are set by the par array using the

*  offset of the table above as:

*

*  A=par[offset];

*  B=par[offset+4];

*  S=par[offset+8];

*


*/

  /// Function to Apply Muon Smearing

 void ActAsSmeared(Float_t * par, bool zjpsiparams=1);


  /// Function to Apply Muon Smearing pre-shutdown 2004 parameter, code by Raimund Stroehmer

  void ActAsSmeared_pre();

  /// Function to Apply Muon Smearing post-shutdown 2004 parameter, code by Raimund Stroehmer

  void ActAsSmeared_post();

  /*! @} */


  ~TMBMuon() {;}


  // different muon types

  /// return local muon parameters measured in the muon chambers (no calorimeter eloss correction)

  const TMBMuonType& Local()            const{return _local;}

  /// return local muon parameters measured in the muon chambers w/ calorimeter eloss correction

  const TMBMuonType& LocalCorr()        const{return _localcorr;}

  /// return muon parameters from its matched central track

  const TMBMuonType& Central()            const{return _central;}

  /// return muon parameters from its matched central track w/ CFT only track correction

  const TMBMuonType& CentralCorr()        const{return _centralcorr;}

  /// return global muon parameters from the global fit between local and central parameters

  const TMBMuonType& Global()            const{return _global;}

  /// return MC smeared muon parameters

  const TMBMuonType& SmearedMC()        const{return _smearedMC;}


  // general methods, those of TMBMuonType (additionnal those of TMBLorentzVector)

  /// charge of the muon

  Int_t       charge()  const;

  /// muon tan(lambda)

  Double_t    tlm()     const;

  /// error on phi

  Double_t    err_phi() const;

  /// error on (physical) eta

  Double_t    err_eta() const;

  /// transverse momentum error

  Double_t    err_pT()  const;


  // muon system info:

  /// number of hits in the muon chambers,  defined as (nwhitA+10*nwhitBC+1000*nshitA+10000*nshitBC

  Int_t      
nhit()           
    const {return _nhit;}

  /// Matching decks, defined as (nwdeckA+10*nwdeckBC+1000*nsdeckA+10000*nsdeckBC)

  Int_t      
ndeck()                  
const {return _ndeck;}

  /// region in the muon system (0: central, 1: forward z<0, 2: forward z>0)

  Int_t      
region()                 
const {return _region;}

  /// octant in the muon system (from 0 to 7 starting at phi=0)

  Int_t      
octant()                 
const {return _octant;}

  /// Chisquare from local muon chamber fitting

  Float_t    
chisqloc()           
const {return _chisqloc ;}

  /// Scintillator time for A-segment

  Float_t    
sctimeA()           
    const {return _sctimeA ;}

  /// Scintillator time for B-segment

  Float_t    
sctimeB()           
    const {return _sctimeB ;}

  /// Scintillator time for C-segmen

  Float_t     sctimeC()   
        const {return _sctimeC ;}

  /// x coordinate of center point of A-segment (x local position)

  Float_t    
xA()           
    const {return _xA ;}

  /// y coordinate of center point of A-segment (y local position)

  Float_t    
yA()           
    const {return _yA ;}

  /// z coordinate of center point of A-segment (z local position)

  Float_t    
zA()           
    const {return _zA;}

  /// B dl of the muon through the toroid (not filled yet)

  Float_t     bdl()            const {return _bdl;}


  /// number of A layer wire hits associated to the muon

  Int_t  wireHitsA() const;

  /// number of B layer wire hits associated to the muon

  Int_t  wireHitsB() const;

  /// number of C layer wire hits associated to the muon

  Int_t  wireHitsC() const;

  /// number of B+C layer wire hits associated to the muon

  Int_t  wireHitsBC() const;

  /// number of A layer scintillator hits associated to the muon

  Int_t  scintHitsA() const;

  /// number of B layer scintillator hits associated to the muon

  Int_t  scintHitsB() const;

  /// number of C layer scintillator hits associated to the muon

  Int_t  scintHitsC() const;

  /// number of B+C layer scintillator hits associated to the muon

  Int_t  scintHitsBC() const;

  // return muon detector eta at R=rdet (mainly for rdet = A, B or C layer)

  Double_t GetEtaDetector(Double_t eta, Double_t z, Double_t rdet) const;

  /// return recomputed muon detector eta at A layer (take properly into account the muon geometry)

  /// for the moment, can potentially be different from the stored one return by detectorEta()

  Double_t GetEtaDetector(Int_t solpol=0) const;


  /// is the muon in the bottom hole ?

  bool isInHole(Int_t solpol=0) const;

  /// Method used in GetEtaDetector()

  Double_t det_eta(double theta, double phi, double z0) const;


  // matching info:

  /// Matching segments (0: no segments; MTC or hit) (1:A layer; 2:BC; 3:A+BC; negativ: w/o central track)

  Int_t      
nseg()                   
const {return _nseg;}

  /// Number of degree of freedom of the global muon fit

  Int_t      
ndof()            const
{return _ndof;}

  /// delta_phi between A layer segment and the matching charged particle (straight line extrapolation)

  Float_t    
deltaPhi()               
const {return _deltaPhi;}

  /// delta_eta between A layer segment and the matching charged particle (straight line extrapolation)

  Float_t    
deltaEta()               
const {return _deltaEta;}

  /// distance between A layer segment and the matching charged particle (straight line extrapolation)

  Float_t    
deltaDrift()             
const {return _deltaDrift;}

  /// Chisquare from global matching (global muon fit)

  Float_t    
chisq()                  
const {return _chisq;}

  /// z coordinate at Pca (cm) (if matched muon)

  Float_t    
zAtPca()           
    const {return _zAtPca ;}

  /// Impact parameter in xy plane (cm) (if matched muon)

  Float_t    
impPar()           
    const {return _impPar ;}

  /// Muonid impact parameter significance (if matched muon)

  Float_t    
impParSig()       
    const {return _impParSig ;}

  /// Error of impact parameter (if matched muon)

  Float_t    
err_impPar()             
const {return _err_impPar;}

  /// Error of z coordinate at Pca (if matched muon)

  Float_t    
err_zAtPca()             
const {return _err_zAtPca ;}

  /// dca of the track associated with the muon (0 if unmatched)

  Float_t    
dca()         
        const {return _dca;}

  /// Muon detector eta at the A-layer (R=292.059cm)

  Float_t     detectorEta()        const {return _deteta;}

  /// charged particle object associated with the muon (if matched muon)

  TMBTrack*  
GetChargedTrack()         const
{return _chptr.IsValid() ? (TMBTrack*)_chptr.GetObject() : 0;}

  /// TRef to the charged particle object associated with the muon

  const TRef& GetChargedTrackRef()      const {return _chptr;}

  /// vertex object associated with the muon (if matched muon)

  TMBVertex* 
GetVertex()              
const {return _vtxref.IsValid() ? (TMBVertex*)_vtxref.GetObject() : 0;}

  /// TRef to the vertex object associated with the muon

  const TRef& GetVertexRef()            const {return _vtxref;}

  /// global chisquare probability

  Double_t chisqProb() const;


  // MTC info:

  /// Number of layers contribution to the muon signal found by the MTC algorithm

  Int_t      
calnLayer()              
const {return _calnLayer;}

  /// Muon track in calorimeter (MTC): -1 not done, 0 not found, 1 found

  Int_t      
nmtc()                   
const {return _nmtc;}

  /// Energy in cal cells associated with the matching MTC track

  Float_t    
etrack_best()            
const {return _etrack_best;}

  /// Significance of the energy reconstructed by the MTC algorithm

  Float_t    
caleSig()                
const {return _caleSig;}

  /// Rapidity of the muon signal found by the MTC algorithm

  Float_t    
calEta()                 
const {return _calEta;}

  /// Azimuthal angle of the muon signal found by the MTC algorithm

  Float_t    
calPhi()                 
const {return _calPhi;}

  /// Estimation of the muon energy loss in the calorimeter (Run I estimation)

  Float_t     eloss()   
            const
{return _eloss;}

 

  // Isolation info:

  /// Total number of tracks in a cone of radius 0.5 centered around the muon

  Int_t       nTrk5()
       
        const {return _nTrk5;}

  /// Energy in a dR=0.1 cone around the muon

  Float_t    
EInCone1()               
const {return _EInCone1;}

  /// Energy in a dR=0.15 cone around the muon

  Float_t    
EInCone15()              
const {return _EInCone15;}

  /// Energy in a dR=0.2 cone around the muon

  Float_t    
EInCone2()               
const {return _EInCone2;}

  /// Energy in a dR=0.4 cone around the muon

  Float_t    
EInCone4()               
const {return _EInCone4;}

  /// Energy in a dR=0.6 cone around the muon

  Float_t    
EInCone6()               
const {return _EInCone6;}

  /// Distance (R) from the nearest jet reconstructed with the Run II cone algorithm (0.5 cone radius)

  Float_t     drJet5()            const {return _drJet5;}

  /// Total transverse momentum of tracks in a cone of radius 0.5 centered around the muon

  Float_t     etTrkCone5()        const {return _etTrkCone5;}

  /// Total transverse energy measured in the calorimeter in the anulus between 0.1 and 0.4 centered around the muon track

  Float_t     etHalo()            const {return _etHalo;}


  // Flags:

  /// Flag indicating whether the muon passes the loose identification criteria

  Int_t      
isLoose()       
        const { return _isLoose;}

  /// Flag indicating whether the muon passes the medium identification criteria

  Int_t         
isMedium()          
    const { return _isMedium;}

  /// Flag indicating whether the muon passes the tight identification criteria

  Int_t      
isTight()           
    const {return _isTight;}

  /// Flag indicating whether the muon momentum was measured in the muon system

  Int_t      
hasLocal()          
    const {return _hasLocal;}

  /// Flag indicating whether the muon is matched to a central track

  Int_t      
hasCentral()        
    const {return _hasCentral;}

  /// Flag indicating whether the muon was identified as a MIP in the calorimeter (MTC algorithm)

  Int_t      
hasCal()        
        const {return _hasCal;}

  /// Flag indicating whether the muon event is OK (Xing error, crate error, ...)

  Int_t       isMuonEventOK() 
        const {return _isMuonEventOK;}

  /// Flag indicating whether the muon passes timing cuts for cosmic removal

  Int_t       isCosmic()         const {return _isCosmic;}

  /// Flag indicating whether the muon passes timing and dca cuts for cosmic removal

  Int_t       isCosmicT()         const {return _isCosmicT;}


  // Expected number of hits:

  /// Expected number of wire hits in the A layer (not implemented in the thumbnail yet)

  Int_t expWhitsA()      const {return _expWhitsA;}

  /// Expected number of wire hits in the BC layer (not implemented in the thumbnail yet)

  Int_t expWhitsBC()     const {return _expWhitsBC;}

  /// Expected number of scintillator hits in the A layer (not implemented in the thumbnail yet)

  Int_t expShitsA()      const { return _expShitsA;}

  /// Expected number of scintillator hits in the BC layer (not implemented in the thumbnail yet)

  Int_t expShitsBC()     const { return _expShitsBC;}


  /// random number used in MC smearing

  Float_t MCsmearingRand() const { return _rand;}

 

  /// fix the pt of the muons (Because of the bug in the p17 fixer

  /// this methode always must be used for the refixed data)

  void  FixMuonPt();


  ClassDef(TMBMuon, 5)   // TMBTree Muon class

};


#endif


###########################################


##### TMBMuon.cpp #####


//////////////////////////////////////////////////////////////////////////

//                                                                     
//

//      TMBTree Muon
class                                             
//

//                                                                     
//

//////////////////////////////////////////////////////////////////////////


#include "tmb_tree/TMBMuon.hpp"

#include "TError.h"

#include "TMath.h"

#include "tmb_tree/TMBTrack.hpp"

#include "kinem_util/AnglesUtil.hpp"

#include


using namespace std;


namespace {

  Double_t MuonMass = 0.1057;

}


ClassImp(TMBMuon)


//_____________________________________________________________________________

TMBMuon::TMBMuon()

    :  TMBLorentzVector(0,0,0,MuonMass, kPtEtaPhiM),

       _best(kCentralCorr)

{

}


TMBMuon::TMBMuon(Double_t pT, Double_t eta, Double_t phi, Type best,

         const TMBMuonType& local,   const TMBMuonType& localcorr,

         const TMBMuonType& central, const TMBMuonType& centralcorr,

         const TMBMuonType& global,  const TMBMuonType& smearedMC)

    : TMBLorentzVector(pT,eta,phi,MuonMass,kPtEtaPhiM),

      _local(local),

      _localcorr(localcorr),

      _central(central),

      _centralcorr(centralcorr),

      _global(global),

      _smearedMC(smearedMC),

      _best(best)

{

}


void TMBMuon::SetLocalInfo(Int_t nhit, Int_t ndeck, Int_t region, Int_t octant,

               
Float_t chisqloc, Float_t sctimeA, Float_t sctimeB, Float_t sctimeC,

               
Float_t xA, Float_t yA, Float_t zA, Float_t bdl)

{

  _nhit     = nhit;

  _ndeck    = ndeck;

  _region   = region;

  _octant   = octant;

  _chisqloc = chisqloc;

  _sctimeA  = sctimeA;

  _sctimeB  = sctimeB;

  _sctimeC  = sctimeC;

  _xA       = xA;

  _yA       = yA;

  _zA       = zA;

  _bdl      = bdl;

}


void TMBMuon::SetMatchingInfo(Int_t nseg, Int_t ndof,

               
Float_t deltaPhi, Float_t deltaEta, Float_t deltaDrift,

               
Float_t chisq, Float_t zAtPca, Float_t impPar, Float_t impParSig,

               
Float_t err_zAtPca, Float_t err_impPar, Float_t dca,

                TRef chptr, TRef vtxref)

{

  _nseg       = nseg;

  _ndof       = ndof;

  _deltaPhi   = deltaPhi;

  _deltaEta   = deltaEta;

  _deltaDrift = deltaDrift;

  _chisq      = chisq;

  _zAtPca     = zAtPca;

  _impPar     = impPar;

  _impParSig  = impParSig;

  _err_zAtPca = err_zAtPca;

  _err_impPar = err_impPar;

  _dca        = dca;

  _chptr      = chptr;

  _vtxref     = vtxref;

}


void TMBMuon::SetDetEta(Float_t deteta)

{

  _deteta     = deteta;

}


void TMBMuon::SetMTCInfo(Int_t nmtc, Int_t calnLayer, Float_t etrack_best,

               
Float_t caleSig, Float_t calEta, Float_t calPhi, Float_t eloss)

{

  _nmtc        = nmtc;

  _calnLayer   = calnLayer;

  _etrack_best = etrack_best;

  _caleSig     = caleSig;

  _calEta      = calEta;

  _calPhi      = calPhi;

  _eloss       = eloss;

}


void TMBMuon::SetIsolationInfo(Int_t nTrk5, Float_t EInCone1, Float_t EInCone15, Float_t EInCone2,

                Float_t EInCone4, Float_t EInCone6,

               
Float_t drJet5, Float_t etTrkCone5, Float_t etHalo)

{

  _nTrk5      = nTrk5;

  _EInCone1   = EInCone1;

  _EInCone15  = EInCone15;

  _EInCone2   = EInCone2;

  _EInCone4   = EInCone4;

  _EInCone6   = EInCone6;

  _drJet5     = drJet5;

  _etTrkCone5 = etTrkCone5;

  _etHalo     = etHalo;

}


void TMBMuon::SetFlags(Int_t isLoose, Int_t isMedium, Int_t isTight,

               
Int_t hasLocal, Int_t hasCentral, Int_t hasCal,

               
Int_t isMuonEventOK, Int_t isCosmic, Int_t isCosmicT)

{

  _isLoose       = isLoose;

  _isMedium      = isMedium;

  _isTight       = isTight;

  _hasLocal      = hasLocal;

  _hasCentral    = hasCentral;

  _hasCal        = hasCal;

  _isMuonEventOK = isMuonEventOK;

  _isCosmic      = isCosmic;

  _isCosmicT     = isCosmicT;

}


void TMBMuon::SetExpectedHits(Int_t expWhitsA, Int_t expWhitsBC,

          
             
Int_t expShitsA, Int_t expShitsBC)

{

  _expWhitsA      = expWhitsA;

  _expWhitsBC     = expWhitsBC;

  _expShitsA      = expShitsA;

  _expShitsBC     = expShitsBC;

}


void TMBMuon::SetMCsmearingRand(Float_t rand)

{

  _rand = rand;

}


void TMBMuon::CorrectPt(double dca)

{

  //If muo does not have track do not try to correct

  if(!_hasCentral) return;

  const TMBTrack* trk = GetChargedTrack();

  if(trk) {

    double err_rqpt = trk->trerrs(4, 0);

    double err_rr = trk->trerrs(0, 0);

    float qopt = trk->qpt();

    qopt -= dca * err_rqpt / err_rr;

    double pTcorr = 1 / qopt;

    int q = 1;

    if(pTcorr<0) {

      pTcorr *= -1;

      q = -1;

    }

    double scale = pTcorr / trk->Pt();

    double corrpx = scale * trk->Px();

    double corrpy = scale * trk->Py();

    double corrpz = scale * trk->Pz();

    double corrE = scale * trk->E();


    //change TMBMuon 4-vector

    SetPxPyPzE(corrpx,corrpy,corrpz,corrE);

    //change _centralcorr 4-vector & charge

    TMBMuonType new_centralcorr(pTcorr,Eta(),Phi(),err_pT(),err_eta(),err_phi(),q);

    _centralcorr = new_centralcorr;

    //Set best muon info to CentralCorr

    _best = TMBMuon::kCentralCorr;

  }


}


Int_t TMBMuon::charge() const

{

  switch(_best) {

    case kLocalCorr: return _localcorr.charge();

    case kCentralCorr: return _centralcorr.charge();

    case kSmearedMC: return _smearedMC.charge();

    default: Error("TMBMuon::charge","bad best muon type");

  }

  return 0;

}


Double_t TMBMuon::tlm() const

{

  switch(_best) {

    case kLocalCorr: return _localcorr.tlm();

    case kCentralCorr: return _centralcorr.tlm();

    case kSmearedMC: return _smearedMC.tlm();

    default: Error("TMBMuon::tlm","bad best muon type");

  }

  return 0;

}


Double_t TMBMuon::err_phi() const

{

  switch(_best) {

    case kLocalCorr: return _localcorr.err_phi();

    case kCentralCorr: return _centralcorr.err_phi();

    case kSmearedMC: return _smearedMC.err_phi();

    default: Error("TMBMuon::err_phi","bad best muon type");

  }

  return 0;

}


Double_t TMBMuon::err_eta() const

{

  switch(_best) {

    case kLocalCorr: return _localcorr.err_eta();

    case kCentralCorr: return _centralcorr.err_eta();

    case kSmearedMC: return _smearedMC.err_eta();

    default: Error("TMBMuon::err_eta","bad best muon type");

  }

  return 0;

}


Double_t TMBMuon::err_pT() const

{

  switch(_best) {

    case kLocalCorr: return _localcorr.err_pT();

    case kCentralCorr: return _centralcorr.err_pT();

    case kSmearedMC: return _smearedMC.err_pT();

    default: Error("TMBMuon::err_pT","bad best muon type");

  }

  return 0;

}


Int_t TMBMuon::wireHitsA() const

{

  return (_nhit % 10);

}


Int_t TMBMuon::wireHitsB() const

{

  return (_nhit / 10)%10;

}


Int_t TMBMuon::wireHitsC() const

{

  return (_nhit / 100)%10;

}


Int_t TMBMuon::wireHitsBC() const

{

  return (wireHitsB() + wireHitsC());

}


int TMBMuon::scintHitsA() const {

  return (_nhit / 1000)%10;

}


int TMBMuon::scintHitsBC() const {

  return scintHitsB() + scintHitsC();

}


int TMBMuon::scintHitsB() const {

  return (_nhit/10000)%10;

}


int TMBMuon::scintHitsC() const {

  return (_nhit/100000)%10;

}


Double_t TMBMuon::GetEtaDetector(Double_t eta, Double_t z, Double_t rdet) const

{

  float z0 = z + rdet*sinh(eta);

  float temp = z0/rdet + sqrt(z0*z0/rdet/rdet + 1.);

  return (temp>0?log(temp):eta);

}


bool TMBMuon::isInHole(Int_t solpol) const

{

 double deta = GetEtaDetector(solpol);

 return ( fabs(deta)<1.25 && this->Phi()>4.25 && this->Phi()<5.15);

}


Double_t TMBMuon::GetEtaDetector(Int_t solpol) const

{

 double theta = this->Theta();

 double phi   = this->Phi();

 double qpt   = (this->Pt()==0)?0:this->charge()/this->Pt();

 phi+= solpol *qpt *0.36; // correction for bending in soleneoid

 double z0    = _zAtPca;

 double deta = -99.;

 TMBTrack* track = this->GetChargedTrack();

 if(track){

   theta = track->Theta();

   phi = track->Phi();

   z0  = track->z();

   deta = det_eta(theta, phi, z0);

 } else {

   deta = kinem::eta(_xA,_yA,_zA);

 }


 return deta;

}


Double_t TMBMuon::det_eta(double theta, double phi, double z0) const

{

   float x_A = 292.;

   float y_A = 294.;

   float z_A = 442.;

   float pi = kinem::PI;


   if(phi<0) phi += 2*pi;

   if(phi>2*pi) phi -= 2*pi;


   double x = 0;

   double y = 0;

   double z = 0;

   int forward = 0;


   if(theta < pi/2) z = z_A;

   else z = -z_A;


   //see if we hit the forward or backward system:

   double r = fabs( (z - z0)*tan(theta) );

   x = r*cos(phi);

   y = r*sin(phi);

   if (fabs(x)<x_A && fabs(y)<y_A) forward = 1;


   //otherwise calculate x, y and z for central:

   if(!forward){

     if(phi > 7*pi/4 || phi < pi/4){

       x = x_A;

       y = x* tan(phi);

     }

     else if(phi > pi/4 && phi < 3*pi/4){

       y = y_A;

       x = y/tan(phi);

     }

     else if(phi > 3*pi/4 && phi < 5*pi/4){

       x = -x_A;

       y = x* tan(phi);

     }

     else if(phi > 5*pi/4 && phi < 7*pi/4){

       y = -y_A;

       x = y/tan(phi);

     }


     r = sqrt(x*x + y*y);

     z = z0 + r/tan(theta);

   }


   float eta = -log( tan( atan2(r,z)/2));

   return eta;

}


Double_t TMBMuon::chisqProb() const

{

  return TMath::Prob(_chisq,_ndof);

}


// Interface to apply Muon Smearing added 8 Feb 2006

void TMBMuon::ActAsSmeared(Float_t * par, bool zjpsiparams) {

  float rndnum=MCsmearingRand();

 if ( rndnum>98 ) return; // random number not set

//   if ( rndnum>98 ){

//       rndnum=RandGauss::shoot();   // random number used for smearing

//       SetMCsmearingRand(rndnum);

//   }

  if ( !hasCentral() || GetChargedTrack() == NULL  ) return;

  int numSMTHits = GetChargedTrack()->nsmt();      // number of hits in the SMT

  int numCFTHits = GetChargedTrack()->ncft();       // number of hits in the CFT

  int ncft_cut=0;

  float eta_cut=100;

  float eta_cft_cut=100;

  int ipar_off=0;       // parameter offset +1 for large eta or few cft hit

                       
//                 
+2 for no smt hits

  TMBMuonType Muon;

  float q_over_pt;

  if (numSMTHits == 0 )
{                     
// smear vertex corrected pt if no SMT hits

    Muon=CentralCorr();

    ipar_off+=2;

    ncft_cut=int(par[I_nosmt_ncft_cut_TMBMuon]+0.5);

    eta_cut =par[I_nosmt_eta_cut_TMBMuon];

    eta_cft_cut =par[I_nosmt_eta_cft_cut_TMBMuon];

  } else {

    Muon=Central();

    ncft_cut=int(par[I_smt_ncft_cut_TMBMuon]+0.5);

    eta_cut =par[I_smt_eta_cut_TMBMuon];

    eta_cft_cut =par[I_smt_eta_cft_cut_TMBMuon];

  }

  float det_etaCFT=0;

  if ( GetChargedTrack() != NULL )  det_etaCFT=GetChargedTrack()->det_etaCFT();

  if ( Muon.Pt()< 1e-4) return;


  if (!zjpsiparams) {

    if ( fabs(det_etaCFT) >  eta_cft_cut ||
fabs(Muon.Eta() ) >  eta_cut || numCFTHits <  ncft_cut )

      ipar_off+=1;

    float par_A=par[ipar_off+I_par_A_TMBMuon];

    float par_B=par[ipar_off+I_par_B_TMBMuon];

    float par_Bpt=par[ipar_off+I_par_Bpt_TMBMuon];

    float scale=par[ipar_off+I_scale_TMBMuon];

    float width=par_A+par_B/Muon.Pt()+par_Bpt*Muon.Pt();

    q_over_pt = scale*Muon.charge()/Muon.Pt()+width*rndnum;

  } else {

    if ( fabs(det_etaCFT) > eta_cft_cut) ipar_off+=1;

    float par_A=par[ipar_off+I_par_A_TMBMuon];

    float par_B=par[ipar_off+I_par_B_TMBMuon];

    float coshpt = cosh(Muon.Eta())/Muon.Pt()/Muon.Pt();

    float width  =  sqrt(par_A*par_A + par_B*par_B*coshpt);

    q_over_pt    = Muon.charge()/Muon.Pt()+width*rndnum;

    // cout << " numSMTHits=" << numSMTHits
<< ", det_etaCFT=" << det_etaCFT << ", par_A="
<< par_A << ", par_B=" << par_B << endl;

  } // else name.find("zjpsi")


  float pT=Muon.Pt();

  if (q_over_pt != 0 ) pT=fabs(1/q_over_pt);

  int charge_sm=1;

  if (q_over_pt<0)  charge_sm=-1;

  TMBMuonType smear_muon(pT, Muon.Eta(),Muon.Phi(),

    Muon.err_pT(), Muon.err_eta(), Muon.err_phi(),

    charge_sm);

  _smearedMC = smear_muon;

  _best=  kSmearedMC;

  this->SetPtEtaPhiM(pT,this->Eta(),this->Phi(),this->M());

  return;


}


void TMBMuon::ActAsSmeared_pre()

{

  float par[npar_TMBMuon];

// smaring parameter for pre shutown data

  par[I_par_A_TMBMuon+0]=0.0011;

  par[I_par_A_TMBMuon+1]=0.0000;

  par[I_par_A_TMBMuon+2]=0.0009;

  par[I_par_A_TMBMuon+3]=0.0009;

  par[I_par_B_TMBMuon+0]=0.013;

  par[I_par_B_TMBMuon+1]=0.000;

  par[I_par_B_TMBMuon+2]=0.018;

  par[I_par_B_TMBMuon+3]=0.018;

  par[I_par_Bpt_TMBMuon+0]=0.0;

  par[I_par_Bpt_TMBMuon+1]=0.0;

  par[I_par_Bpt_TMBMuon+2]=0.0;

  par[I_par_Bpt_TMBMuon+3]=0.0;

  par[I_scale_TMBMuon+0]=1;

  par[I_scale_TMBMuon+1]=1;

  par[I_scale_TMBMuon+2]=1;

  par[I_scale_TMBMuon+3]=1;

  par[I_smt_ncft_cut_TMBMuon]=0;

  par[I_nosmt_ncft_cut_TMBMuon]=0;

  par[I_smt_eta_cut_TMBMuon]=1.5;

  par[I_nosmt_eta_cut_TMBMuon]=1.5;

  par[I_smt_eta_cft_cut_TMBMuon]=0.;

  par[I_nosmt_eta_cft_cut_TMBMuon]=0.;

   ActAsSmeared(par,"dummy");

  return;

}


void TMBMuon::ActAsSmeared_post()

{

  float par[npar_TMBMuon];

// smaring parameter for pre shutown data

  par[I_par_A_TMBMuon+0]=0.0015;

  par[I_par_A_TMBMuon+1]=0.0016;

  par[I_par_A_TMBMuon+2]=0.0017;

  par[I_par_A_TMBMuon+3]=0.0017;

  par[I_par_B_TMBMuon+0]=0.018;

  par[I_par_B_TMBMuon+1]=0.019;

  par[I_par_B_TMBMuon+2]=0.034;

  par[I_par_B_TMBMuon+3]=0.034;

  par[I_par_Bpt_TMBMuon+0]=0.0;

  par[I_par_Bpt_TMBMuon+1]=0.0;

  par[I_par_Bpt_TMBMuon+2]=0.0;

  par[I_par_Bpt_TMBMuon+3]=0.0;

  par[I_scale_TMBMuon+0]=1;

  par[I_scale_TMBMuon+1]=1;

  par[I_scale_TMBMuon+2]=1;

  par[I_scale_TMBMuon+3]=1;

  par[I_smt_ncft_cut_TMBMuon]=0;

  par[I_nosmt_ncft_cut_TMBMuon]=0;

  par[I_smt_eta_cut_TMBMuon]=1.5;

  par[I_nosmt_eta_cut_TMBMuon]=1.5;

  par[I_smt_eta_cft_cut_TMBMuon]=0.;

  par[I_nosmt_eta_cft_cut_TMBMuon]=0.;

  ActAsSmeared(par,"dummy");

  return;

}


void TMBMuon:: FixMuonPt(){

  TMBMuonType* best;

  switch(_best) {

  case kLocalCorr:    best= &_localcorr; break;

  case kCentralCorr:  best=&_centralcorr; break;

  case kSmearedMC  :  best=&_smearedMC; break;

  default:  Error("TMBMuon::FixMuonPt","bad best muon type");

 }


  SetPxPyPzE(best->X(),best->Y(),best->Z(),best->E());


}


//______________________________________________________________________________


Je te remercie infiniment pour ton aide

Jerome
0
cs_jeje42 Messages postés 3 Date d'inscription jeudi 2 avril 2009 Statut Membre Dernière intervention 4 avril 2009
4 avril 2009 à 22:32
Maintenant le programme compile :  j'ai pour cela commente les lignes suivantes :

ClassDef(Muonjj,5); # dans le header

ClassImp(Muonjj) # dans le fichier source


 mais malheureusement celui-ci ne s'execute pas encore correctement,
avec le message d'erreur :



Warning in <TClass::TClass>: no dictionary for class EventWeight is available


Error in <TClonesArray::TClonesArray>: Muonjj is not a valid class name


Error in <TClonesArray::TClonesArray>: Muonjj is not a valid class name


Error in <TTree::Bronch>: TClonesArray with no class defined in branch: b_Muonjj


Error in <TTree::Bronch>: TClonesArray with no class defined in branch: b_LooseMuonjj


Execution du constructeur de la classe MuonjjExecution du constructeur
de la classe
Muonjj******************************************************************************


*Tree :mycopy : copy from TMBTree *


*Entries : 219 : Total 310 bytes File Size 310 *


* : : Tree compression factor = 1.00 *


******************************************************************************



Le programme cree la structure de l'arbre, mais pas les branches et ma classe n'est pas reconnue..



Quelqu'un a une idee ?


Je vous en serai tres reconnaissant, ce programme est vraiment crucial pour moi !



Merci


Jerome
0
Rejoignez-nous