// Author: M.A. Kagarlis
// Written: 31.01.99
// Revised: 23.7.2007  IF
// PData Class Header

#ifndef _PDATA_H_
#define _PDATA_H_

#include "TROOT.h"
#include "TMath.h"
#include <iostream>
#include "PStaticData.h"

using namespace std;

class PData : public TObject {
      
 public:

  static void SetWeightVersion(Int_t i) {
      //PData::WeightVersion = i;
      *(makeStaticData()->GetBatchValue("_system_weight_version")) 
	  = (Double_t) i;
  }

  void SetUnstableWidth(Double_t m) {
      *(makeStaticData()->GetBatchValue("_system_unstable_width")) = m;
  };



  static double LMass(const int &id) {
      // lower mass limit, by particle pid      

      Double_t *mass;

      if (makeDataBase()->GetParamDouble ((char*)"pid", id, (char*)"lmass", &mass)) {
	  return *mass;
      }

      if ( makeStaticData()->GetParticleTotalWidth(id) < 1.e-3 ) {
	  // (quasi)stable
	  return 0.999*makeStaticData()->GetParticleMass(id);      
      }
//  else if ( id==41 ) return 2.*PMass[8];                 // rho0
      else if (id == 41)                                   // rho0
	  return 2.*makeStaticData()->GetParticleMass(2);                 
      else if (id == 42 || id == 43)                          // rho+,rho-
	  return makeStaticData()->GetParticleMass(8)+
	      makeStaticData()->GetParticleMass(7);  
      else if (id == 52)                                   // omega
	  return 2.*makeStaticData()->GetParticleMass(2);                 
      else if (id == 55)                                   // phi
	  return 3.*makeStaticData()->GetParticleMass(2);                 
      else if (makeStaticData()->GetParticleBaryon(id))  // resonance
	  return makeStaticData()->GetParticleMass(14);               
      else if (makeStaticData()->GetParticleTotalWidth(id) > 0.01) 
	  return TMath::Max(0., 0.999*(makeStaticData()->GetParticleMass(id)-
				       5.*makeStaticData()->GetParticleTotalWidth(id)));
      else 
	  return TMath::Max(0., 0.999*(makeStaticData()->GetParticleMass(id)-
				       15.*makeStaticData()->GetParticleTotalWidth(id)));
  }
  
  static double LMass(const char *id) { 
      // lower mass limit, by name
      return LMass(makeStaticData()->IsParticleValid(id)); 
  }

  static double UMass(const int &id) {
      // upper mass limit, by particle pid

      Double_t *mass;
      if (makeDataBase()->GetParamDouble ((char*)"pid", id, (char*)"umass", &mass)) return *mass;

      if (id==50 || makeStaticData()->IsParticle(id,"dilepton")) // dilepton
	  return 1.e10;        
      else if (makeStaticData()->GetParticleTotalWidth(id) < 1.e-3)   // (quasi)stable
	  return 1.001*makeStaticData()->GetParticleMass(id); 
      //      else return makeStaticData()->GetParticleMass(id)+1.;      // just go 1 GeV above pole
      else return makeStaticData()->GetParticleMass(id)
	       +10.*makeStaticData()->GetParticleTotalWidth(id);  //better in units of sigma
  }

  
  static double UMass(const char * id) { 
      // upper mass limit, by name
      return UMass(makeStaticData()->IsParticleValid(id)); 
  }



public:


  static int IsDelta(const int &id) {
    // check if id corresponds to a Delta
    return (id == makeStaticData()->GetParticleID("D++")||
	    id == makeStaticData()->GetParticleID("D+") ||
	    id == makeStaticData()->GetParticleID("D0") ||
	    id == makeStaticData()->GetParticleID("D-"));
  }

  static int IsN1535(const int &id) {
    // check if id corresponds to a S11(1535) resonance
    return (id == makeStaticData()->GetParticleID("NS11+")||
	    id == makeStaticData()->GetParticleID("NS110"));
  }
  
  static int IsPi(const int &id) {
    // check if id corresponds to a pion
    return (id == makeStaticData()->GetParticleID("pi0")||
	    id == makeStaticData()->GetParticleID("pi+")||
	    id == makeStaticData()->GetParticleID("pi-"));
  }
  
  static int IsN(const int &id) { 
      // check if id corresponds to a nucleon
      return (id == makeStaticData()->GetParticleID("p")||
	      id == makeStaticData()->GetParticleID("n")); }
  
  static int IsRho(const int &id) {
      // check if id corresponds to a rho meson
      return (id == makeStaticData()->GetParticleID("rho0")||
	      id == makeStaticData()->GetParticleID("rho+")||
	      id == makeStaticData()->GetParticleID("rho-"));
  }
  
  static int IsNPiPi(const int &i1, const int &i2, const int &i3) {
      // checks if i1+i2+i3 are N+pi+pi
      return ((IsN(i1) && IsPi(i2) && IsPi(i3))||
	      (IsN(i2) && IsPi(i1) && IsPi(i3))|| 
	      (IsN(i3) && IsPi(i1) && IsPi(i2)));
  }
  
  static int IsDalitz(const int &id, const int &i1, const int &i2) {
      // checks if the decay id->i1+i2 is a known Dalitz decay
      int eeg = 
	  (makeStaticData()->IsParticle(i1,"dilepton") && 
	   makeStaticData()->IsParticle(i2,"g")) || 
	  (makeStaticData()->IsParticle(i1,"g") && 
	   makeStaticData()->IsParticle(i2,"dilepton")); // e+e-gamma?
      int mumug = 
	  (makeStaticData()->IsParticle(i1,"dimuon") && 
	   makeStaticData()->IsParticle(i2,"g")) || 
	  (makeStaticData()->IsParticle(i1,"g") && 
	   makeStaticData()->IsParticle(i2,"dimuon"));   // mu+mu-gamma?
      int eepi = 
	  (makeStaticData()->IsParticle(i1,"dilepton") && 
	   makeStaticData()->IsParticle(i2,"pi0")) || 
	  (makeStaticData()->IsParticle(i1,"pi0") && 
	   makeStaticData()->IsParticle(i2,"dilepton")); // e+e-pi0?
      int mumupi = 
	  (makeStaticData()->IsParticle(i1,"dimuon") && 
	   makeStaticData()->IsParticle(i2,"pi0")) || 
	  (makeStaticData()->IsParticle(i1,"pi0") && 
	   makeStaticData()->IsParticle(i2,"dimuon"));   // mu+mu-pi0?
//  int eeeta = (Is(i1,"dilepton")&&Is(i2,"eta")) || (Is(i1,"eta")&&Is(i2,"dilepton")); // e+e-eta?
      
      int pseudo = 
	  (makeStaticData()->IsParticle(id,"eta") || 
	   makeStaticData()->IsParticle(id,"eta'") || 
	   makeStaticData()->IsParticle(id,"pi0")); // pseudo-scalar meson?
      int vector = 
	  (makeStaticData()->IsParticle(id,"w") || 
	   makeStaticData()->IsParticle(id,"phi") || 
	   makeStaticData()->IsParticle(id,"J/Psi"));  // vector meson?

      int d = makeStaticData()->GetParticleBaryon(id) &&  // Baryon Dalitz decay in general?
	  ((makeStaticData()->IsParticle(i1,"dilepton") && 
	    makeStaticData()->GetParticleBaryon(i2)) || 
	   (makeStaticData()->GetParticleBaryon(i1) && 
	    makeStaticData()->IsParticle(i2,"dilepton")));

#if 1
      int D0 = 
	  makeStaticData()->IsParticle(id,"D0") &&  // Delta0 Dalitz decay?
	  ((makeStaticData()->IsParticle(i1,"dilepton") && 
	    makeStaticData()->IsParticle(i2,"n")) || 
	   (makeStaticData()->IsParticle(i1,"n") && 
	    makeStaticData()->IsParticle(i2,"dilepton")));
      int Dp = 
	  makeStaticData()->IsParticle(id,"D+") &&  // Delta+ Dalitz decay?
	  ((makeStaticData()->IsParticle(i1,"dilepton") && 
	    makeStaticData()->IsParticle(i2,"p")) || 
	   (makeStaticData()->IsParticle(i1,"p") && 
	    makeStaticData()->IsParticle(i2,"dilepton")));
      int D0m = 
	  makeStaticData()->IsParticle(id,"D0") &&  // Delta0 Dalitz decay?
	  ((makeStaticData()->IsParticle(i1,"dimuon") && 
	    makeStaticData()->IsParticle(i2,"n")) || 
	   (makeStaticData()->IsParticle(i1,"n") && 
	    makeStaticData()->IsParticle(i2,"dimuon")));
      int Dpm = 
	  makeStaticData()->IsParticle(id,"D+") &&  // Delta+ Dalitz decay?
	  ((makeStaticData()->IsParticle(i1,"dimuon") && 
	    makeStaticData()->IsParticle(i2,"p")) || 
	   (makeStaticData()->IsParticle(i1,"p") && 
	    makeStaticData()->IsParticle(i2,"dimuon")));
      int pn = 
	  makeStaticData()->IsParticle(id,"pn") &&   // pn bremsstrahlung?
	  ((makeStaticData()->IsParticle(i1,"dilepton") && 
	    makeStaticData()->IsParticle(i2,"p")) || 
	   (makeStaticData()->IsParticle(i1,"p") && 
	    makeStaticData()->IsParticle(i2,"dilepton")));
      int NS0 = 
	  makeStaticData()->IsParticle(id,"NS110") && // N(1535)0 Dalitz decay?
	  ((makeStaticData()->IsParticle(i1,"dilepton") && 
	    makeStaticData()->IsParticle(i2,"n")) || 
	   (makeStaticData()->IsParticle(i1,"n") && 
	    makeStaticData()->IsParticle(i2,"dilepton")));
      int NSp = 
	  makeStaticData()->IsParticle(id,"NS11+") && // N(1535)+ Dalitz decay?
	  ((makeStaticData()->IsParticle(i1,"dilepton") && 
	    makeStaticData()->IsParticle(i2,"p")) || 
	   (makeStaticData()->IsParticle(i1,"p") && 
	    makeStaticData()->IsParticle(i2,"dilepton")));
#endif     
 
      return (pseudo&&eeg) || (pseudo&&mumug) || 
	  (vector&&eepi) || (vector&&mumupi)
	  || D0m || Dpm || D0 || Dp || pn || NS0 || NSp || d;
  }
  
  static int IsDalitz(int * i) {
    // as above, for pid array

    if (!i) return 0;
    return IsDalitz(i[0],i[1],i[2]);
  }

  static int IsDalitz(const int &idx) {
    // checks if idx is the index of a Dalitz decay mode

      int i[10];
      
      i[0] = 2; //max 2 particles
      makeStaticData()->GetDecayMode(idx,i);
      if (*i != 2) return 0; // other than two products in this decay mode
      return IsDalitz(makeStaticData()->GetDecayParent(idx), i[1], i[2]);
  }

  static int IsPseudoscalarDalitz(const int &id, const int &i1, const int &i2) {
    // checks if the decay id->i1+i2 is a known pseudoscalar Dalitz decay

    int eeg = 
	(makeStaticData()->IsParticle(i1,"dilepton") && 
	 makeStaticData()->IsParticle(i2,"g")) || 
	(makeStaticData()->IsParticle(i1,"g") && 
	 makeStaticData()->IsParticle(i2,"dilepton")); // e+e-gamma?
    int mumug = 
	(makeStaticData()->IsParticle(i1,"dimuon") && 
	 makeStaticData()->IsParticle(i2,"g")) || 
	(makeStaticData()->IsParticle(i1,"g") && 
	 makeStaticData()->IsParticle(i2,"dimuon"));   // mu+mu-gamma?

    int pseudo = 
	(makeStaticData()->IsParticle(id,"eta") || 
	 makeStaticData()->IsParticle(id,"eta'") || 
	 makeStaticData()->IsParticle(id,"pi0")); // pseudo-scalar meson?
    
    return (pseudo&&eeg) || (pseudo&&mumug);
  }

  static int IsPseudoscalarDalitz(int *i) {
    // as above, for pid array

    if (!i) return 0;
    return IsPseudoscalarDalitz(i[0], i[1], i[2]);
  }

  static int IsPseudoscalarDalitz(const int &idx) {
    // checks if idx is the index of a Dalitz decay mode
        int i[10];

    i[0]=2; //max 2 particles
    makeStaticData()->GetDecayMode(idx, i);
    if (*i != 2) 
	return 0; // other than two products in this decay mode
    return 
	IsPseudoscalarDalitz(makeStaticData()->GetDecayParent(idx), i[1], i[2]);
  }

  static int IsDirectEE(const int &id, const int &i1, const int &i2) {
    // checks if the decay id->i1+i2 is a direct vector-meson ee decay
    
    return 
	(makeStaticData()->IsParticleMeson(id) && 
	 ((makeStaticData()->IsParticle(i1,"e+") && 
	   makeStaticData()->IsParticle(i2,"e-"))||
	  (makeStaticData()->IsParticle(i1,"e-") && 
	   makeStaticData()->IsParticle(i2,"e+"))));
  }

  static int IsDirectEE(const int &idx) {
    // checks if idx is the index of a direct vector-meson ee decay
      int i[10];
    i[0] = 2; //max 2 particles
    makeStaticData()->GetDecayMode(idx, i);
    if (*i != 2) 
	return 0; // other than two products in this decay mode
    return 
	IsDirectEE(makeStaticData()->GetDecayParent(idx), i[1], i[2]);
  }

  static int IsDirectMuMu(const int &id, const int &i1, const int &i2) {
    // checks if the decay id->i1+i2 is a direct vector-meson mumu decay
    
    return 
	(makeStaticData()->IsParticleMeson(id) && 
	 ((makeStaticData()->IsParticle(i1,"mu+") && 
	   makeStaticData()->IsParticle(i2,"mu-"))||
	  (makeStaticData()->IsParticle(i1,"mu-") && 
	   makeStaticData()->IsParticle(i2,"mu+"))));
  }

  static int IsDirectMuMu(const int &idx) {
    // checks if idx is the index of a direct vector-meson mumu decay
      int i[10];
 
    i[0] = 2; //max 2 particles
    makeStaticData()->GetDecayMode(idx, i);
    if (*i != 2) return 0; // other than two products in this decay mode
    return IsDirectMuMu(makeStaticData()->GetDecayParent(idx), i[1], i[2]);
  }

  // static int isWide(const int &);
  // returns total width index

  static int LPW(const int &, const int &, const int &);
  // lowest allowed transition partial wave, for parent id --> pid = i1 & i2

  static int IsMDalitz(const int &);
  // checks if decay mode with index idx is a mesonic Dalitz decay
  

  static Float_t mtIntegral(Double_t m, Float_t T) { // integral of thermal
                                                     // mt distribution
      if (m<=0. || T<=0.) return 0.;
      return T*exp(-m/T)*sqrt(m)*(1.5*T+m)
	  + 1.329340*pow((double)T,(double)2.5)*(1.-TMath::Erf(sqrt(m/T)));
  }

  ClassDef(PData, 1) //Pluto Particle Data Tool Class
};


class PSplash;
R__EXTERN PSplash *gSplash;

class PSplash : public TObject {

 public:

    PSplash();
    
 protected:
    ClassDef(PSplash, 0) //Pluto welcome message

};

#endif // _PDATA_H_







 PData.h:1
 PData.h:2
 PData.h:3
 PData.h:4
 PData.h:5
 PData.h:6
 PData.h:7
 PData.h:8
 PData.h:9
 PData.h:10
 PData.h:11
 PData.h:12
 PData.h:13
 PData.h:14
 PData.h:15
 PData.h:16
 PData.h:17
 PData.h:18
 PData.h:19
 PData.h:20
 PData.h:21
 PData.h:22
 PData.h:23
 PData.h:24
 PData.h:25
 PData.h:26
 PData.h:27
 PData.h:28
 PData.h:29
 PData.h:30
 PData.h:31
 PData.h:32
 PData.h:33
 PData.h:34
 PData.h:35
 PData.h:36
 PData.h:37
 PData.h:38
 PData.h:39
 PData.h:40
 PData.h:41
 PData.h:42
 PData.h:43
 PData.h:44
 PData.h:45
 PData.h:46
 PData.h:47
 PData.h:48
 PData.h:49
 PData.h:50
 PData.h:51
 PData.h:52
 PData.h:53
 PData.h:54
 PData.h:55
 PData.h:56
 PData.h:57
 PData.h:58
 PData.h:59
 PData.h:60
 PData.h:61
 PData.h:62
 PData.h:63
 PData.h:64
 PData.h:65
 PData.h:66
 PData.h:67
 PData.h:68
 PData.h:69
 PData.h:70
 PData.h:71
 PData.h:72
 PData.h:73
 PData.h:74
 PData.h:75
 PData.h:76
 PData.h:77
 PData.h:78
 PData.h:79
 PData.h:80
 PData.h:81
 PData.h:82
 PData.h:83
 PData.h:84
 PData.h:85
 PData.h:86
 PData.h:87
 PData.h:88
 PData.h:89
 PData.h:90
 PData.h:91
 PData.h:92
 PData.h:93
 PData.h:94
 PData.h:95
 PData.h:96
 PData.h:97
 PData.h:98
 PData.h:99
 PData.h:100
 PData.h:101
 PData.h:102
 PData.h:103
 PData.h:104
 PData.h:105
 PData.h:106
 PData.h:107
 PData.h:108
 PData.h:109
 PData.h:110
 PData.h:111
 PData.h:112
 PData.h:113
 PData.h:114
 PData.h:115
 PData.h:116
 PData.h:117
 PData.h:118
 PData.h:119
 PData.h:120
 PData.h:121
 PData.h:122
 PData.h:123
 PData.h:124
 PData.h:125
 PData.h:126
 PData.h:127
 PData.h:128
 PData.h:129
 PData.h:130
 PData.h:131
 PData.h:132
 PData.h:133
 PData.h:134
 PData.h:135
 PData.h:136
 PData.h:137
 PData.h:138
 PData.h:139
 PData.h:140
 PData.h:141
 PData.h:142
 PData.h:143
 PData.h:144
 PData.h:145
 PData.h:146
 PData.h:147
 PData.h:148
 PData.h:149
 PData.h:150
 PData.h:151
 PData.h:152
 PData.h:153
 PData.h:154
 PData.h:155
 PData.h:156
 PData.h:157
 PData.h:158
 PData.h:159
 PData.h:160
 PData.h:161
 PData.h:162
 PData.h:163
 PData.h:164
 PData.h:165
 PData.h:166
 PData.h:167
 PData.h:168
 PData.h:169
 PData.h:170
 PData.h:171
 PData.h:172
 PData.h:173
 PData.h:174
 PData.h:175
 PData.h:176
 PData.h:177
 PData.h:178
 PData.h:179
 PData.h:180
 PData.h:181
 PData.h:182
 PData.h:183
 PData.h:184
 PData.h:185
 PData.h:186
 PData.h:187
 PData.h:188
 PData.h:189
 PData.h:190
 PData.h:191
 PData.h:192
 PData.h:193
 PData.h:194
 PData.h:195
 PData.h:196
 PData.h:197
 PData.h:198
 PData.h:199
 PData.h:200
 PData.h:201
 PData.h:202
 PData.h:203
 PData.h:204
 PData.h:205
 PData.h:206
 PData.h:207
 PData.h:208
 PData.h:209
 PData.h:210
 PData.h:211
 PData.h:212
 PData.h:213
 PData.h:214
 PData.h:215
 PData.h:216
 PData.h:217
 PData.h:218
 PData.h:219
 PData.h:220
 PData.h:221
 PData.h:222
 PData.h:223
 PData.h:224
 PData.h:225
 PData.h:226
 PData.h:227
 PData.h:228
 PData.h:229
 PData.h:230
 PData.h:231
 PData.h:232
 PData.h:233
 PData.h:234
 PData.h:235
 PData.h:236
 PData.h:237
 PData.h:238
 PData.h:239
 PData.h:240
 PData.h:241
 PData.h:242
 PData.h:243
 PData.h:244
 PData.h:245
 PData.h:246
 PData.h:247
 PData.h:248
 PData.h:249
 PData.h:250
 PData.h:251
 PData.h:252
 PData.h:253
 PData.h:254
 PData.h:255
 PData.h:256
 PData.h:257
 PData.h:258
 PData.h:259
 PData.h:260
 PData.h:261
 PData.h:262
 PData.h:263
 PData.h:264
 PData.h:265
 PData.h:266
 PData.h:267
 PData.h:268
 PData.h:269
 PData.h:270
 PData.h:271
 PData.h:272
 PData.h:273
 PData.h:274
 PData.h:275
 PData.h:276
 PData.h:277
 PData.h:278
 PData.h:279
 PData.h:280
 PData.h:281
 PData.h:282
 PData.h:283
 PData.h:284
 PData.h:285
 PData.h:286
 PData.h:287
 PData.h:288
 PData.h:289
 PData.h:290
 PData.h:291
 PData.h:292
 PData.h:293
 PData.h:294
 PData.h:295
 PData.h:296
 PData.h:297
 PData.h:298
 PData.h:299
 PData.h:300
 PData.h:301
 PData.h:302
 PData.h:303
 PData.h:304
 PData.h:305
 PData.h:306
 PData.h:307
 PData.h:308
 PData.h:309
 PData.h:310
 PData.h:311
 PData.h:312
 PData.h:313
 PData.h:314
 PData.h:315
 PData.h:316
 PData.h:317
 PData.h:318
 PData.h:319
 PData.h:320
 PData.h:321
 PData.h:322
 PData.h:323
 PData.h:324
 PData.h:325
 PData.h:326
 PData.h:327
 PData.h:328
 PData.h:329
 PData.h:330
 PData.h:331
 PData.h:332
 PData.h:333
 PData.h:334
 PData.h:335
 PData.h:336
 PData.h:337
 PData.h:338
 PData.h:339
 PData.h:340
 PData.h:341
 PData.h:342
 PData.h:343
 PData.h:344
 PData.h:345
 PData.h:346
 PData.h:347
 PData.h:348
 PData.h:349
 PData.h:350
 PData.h:351
 PData.h:352
 PData.h:353
 PData.h:354
 PData.h:355
 PData.h:356
 PData.h:357
 PData.h:358
 PData.h:359
 PData.h:360
 PData.h:361
 PData.h:362
 PData.h:363
 PData.h:364
 PData.h:365
 PData.h:366
 PData.h:367
 PData.h:368
 PData.h:369