ROOT logo
/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

/* $Id$ */

//-----------------------------------------------------------------------------
// Class AliMUONResponseFactory
// -----------------------------
// Factory for muon response
// Class separated from AliMUONFactoryV4
//-----------------------------------------------------------------------------

#include "AliMUONResponseFactory.h"
#include "AliRun.h"
#include "AliLog.h"

#include "AliMpPlaneType.h"

#include "AliMUON.h"
#include "AliMUONConstants.h"
#include "AliMUONChamber.h"
#include "AliMUONResponseV0.h"
#include "AliMUONResponseTrigger.h"
#include "AliMUONResponseTriggerV1.h"

using std::endl;
/// \cond CLASSIMP
ClassImp(AliMUONResponseFactory)
/// \endcond

//__________________________________________________________________________
  AliMUONResponseFactory::AliMUONResponseFactory(const char* name,
                                                 Bool_t isTailEffect)
    : TNamed(name, ""),
      fMUON(0),
      fResponse0(0),
      fIsTailEffect(isTailEffect)
{
/// Standard constructor
  
  AliDebug(1,Form("ctor this=%p",this));
}

//__________________________________________________________________________
  AliMUONResponseFactory::AliMUONResponseFactory()
    : TNamed(),
      fMUON(0),
      fResponse0(0),
      fIsTailEffect(kTRUE)
{
/// Default constructor

  AliDebug(1,Form("default (empty) ctor this=%p",this));
}

//__________________________________________________________________________

AliMUONResponseFactory::~AliMUONResponseFactory()
{
/// Destructor
	AliDebug(1,Form("dtor this=%p",this));
  delete fResponse0;
}
          
//__________________________________________________________________________
void AliMUONResponseFactory::BuildCommon() 
{
/// Construct the default response.

  // Default response: 5 mm of gas
  fResponse0 = new AliMUONResponseV0;
  fResponse0->SetSqrtKx3AndDeriveKx2Kx4(0.7131); // sqrt(0.5085)
  fResponse0->SetSqrtKy3AndDeriveKy2Ky4(0.7642); // sqrt(0.5840)
  fResponse0->SetPitch(AliMUONConstants::Pitch()); // anode-cathode distance
  fResponse0->SetSigmaIntegration(10.);
  fResponse0->SetChargeSlope(10);
  fResponse0->SetChargeSpread(0.18, 0.18);
  fResponse0->SetMaxAdc(4096);
  fResponse0->SetSaturation(3000);
  fResponse0->SetZeroSuppression(6);
  fResponse0->SetTailEffect(fIsTailEffect);
}       
        
//__________________________________________________________________________
void AliMUONResponseFactory::BuildStation1() 
{
/// Configuration for Chamber TC1/2  (Station 1) ----------           

  // Response for 4 mm of gas (station 1)
  // automatic consistency with width of sensitive medium in CreateGeometry ????
  AliMUONResponseV0 responseSt1;
  // Mathieson parameters from L.Kharmandarian's thesis, page 190
  responseSt1.SetSqrtKx3AndDeriveKx2Kx4(0.7000); // sqrt(0.4900)
  responseSt1.SetSqrtKy3AndDeriveKy2Ky4(0.7550); // sqrt(0.5700)
  responseSt1.SetPitch(AliMUONConstants::PitchSt1()); // anode-cathode distance
  responseSt1.SetSigmaIntegration(10.);
  // ChargeSlope larger to compensate for the smaller anode-cathode distance
  // and keep the same most probable ADC channel for mip's
  responseSt1.SetChargeSlope(25); // SP & JC ajusted to match 2010 real data was 62.5
  // assumed proportionality to anode-cathode distance for ChargeSpread
  responseSt1.SetChargeSpread(0.144, 0.144);
  responseSt1.SetMaxAdc(4096);
  responseSt1.SetSaturation(3000);
  responseSt1.SetZeroSuppression(6);
  responseSt1.SetTailEffect(fIsTailEffect);

   for (Int_t chamber = 0; chamber < 2; chamber++) {
    fMUON->SetResponseModel(chamber, responseSt1); // special response      
    fMUON->Chamber(chamber).SetChargeCorrel(0.11); // 11% charge spread
  }
}

//__________________________________________________________________________
void AliMUONResponseFactory::BuildStation2() 
{
/// Configuration for Chamber TC3/4 (Station 2) -----------

  for (Int_t chamber = 2; chamber < 4; chamber++) {
    fMUON->SetResponseModel(chamber, *fResponse0); // normal response        
    fMUON->Chamber(chamber).SetChargeCorrel(0.11); // 11% charge spread
  }
}       
        
//__________________________________________________________________________
void AliMUONResponseFactory::BuildStation3() 
{
/// Configuration for Chamber TC5/6  (Station 3) ----------          

  for (Int_t chamber = 4; chamber < 6; chamber++) {
    fMUON->SetResponseModel(chamber, *fResponse0); // normal response        
    fMUON->Chamber(chamber).SetChargeCorrel(0.11); // 11% charge spread
  }
}       
        
//__________________________________________________________________________
void AliMUONResponseFactory::BuildStation4() 
{
/// Configuration for Chamber TC7/8  (Station 4) ----------          

  for (Int_t chamber = 6; chamber < 8; chamber++) {
    fMUON->SetResponseModel(chamber, *fResponse0); // normal response        
    fMUON->Chamber(chamber).SetChargeCorrel(0.11); // 11% charge spread
  }
}       
        
//__________________________________________________________________________
void AliMUONResponseFactory::BuildStation5() 
{
/// Configuration for Chamber TC9/10  (Station 5) ---------           

  for (Int_t chamber = 8; chamber < 10; chamber++) {
    fMUON->SetResponseModel(chamber, *fResponse0); // normal response        
    fMUON->Chamber(chamber).SetChargeCorrel(0.11); // 11% charge spread
  }
}       
        
//__________________________________________________________________________
void AliMUONResponseFactory::BuildStation6() 
{
/// Configuration for Trigger Chambers   (Station 6,7) ---------           

    Int_t resTrigV1 = fMUON->GetTriggerResponseV1();    

    for (Int_t chamber = 10; chamber < 14; chamber++) 
    {
      AliMUONResponse* response;
      if(resTrigV1==1 || resTrigV1==2) //cluster size ON
      {
	response = new AliMUONResponseTriggerV1(resTrigV1); //1=STREAMER - 2=AVALANCHE
      }
      
      else // default: clustrer size OFF
      {
	response = new AliMUONResponseTrigger;
      }
      
      fMUON->SetResponseModel(chamber,*response);	
      fMUON->Chamber(chamber).SetChargeCorrel(0); // same charge on both cathodes
      delete response;
    }
}       

//__________________________________________________________________________
void AliMUONResponseFactory::Build(AliMUON* where) 
{
/// Construct MUON responses

  AliDebugStream(1) << "Tail effect: " << fIsTailEffect << endl;

  fMUON = where;

  // Set default parameters
  fMUON->SetIshunt(0);
  fMUON->SetMaxStepGas(0.1);
  fMUON->SetMaxStepAlu(0.1);

  // Build stations
  BuildCommon();
  BuildStation1();
  BuildStation2();
  BuildStation3();
  BuildStation4();
  BuildStation5();
  BuildStation6();
}

//__________________________________________________________________________
void AliMUONResponseFactory::BuildStation(AliMUON* where, Int_t stationNumber) 
{
/// Construct MUON responses for given station

  fMUON = where;
  if (!fResponse0) BuildCommon(); 
    
  switch (stationNumber) {    
    case 1:  BuildStation1(); break;
    case 2:  BuildStation2(); break;
    case 3:  BuildStation3(); break;
    case 4:  BuildStation4(); break;
    case 5:  BuildStation5(); break;
    case 6:  BuildStation6(); break;
    
    default: AliFatal("Wrong station number");
  }  
}         
 AliMUONResponseFactory.cxx:1
 AliMUONResponseFactory.cxx:2
 AliMUONResponseFactory.cxx:3
 AliMUONResponseFactory.cxx:4
 AliMUONResponseFactory.cxx:5
 AliMUONResponseFactory.cxx:6
 AliMUONResponseFactory.cxx:7
 AliMUONResponseFactory.cxx:8
 AliMUONResponseFactory.cxx:9
 AliMUONResponseFactory.cxx:10
 AliMUONResponseFactory.cxx:11
 AliMUONResponseFactory.cxx:12
 AliMUONResponseFactory.cxx:13
 AliMUONResponseFactory.cxx:14
 AliMUONResponseFactory.cxx:15
 AliMUONResponseFactory.cxx:16
 AliMUONResponseFactory.cxx:17
 AliMUONResponseFactory.cxx:18
 AliMUONResponseFactory.cxx:19
 AliMUONResponseFactory.cxx:20
 AliMUONResponseFactory.cxx:21
 AliMUONResponseFactory.cxx:22
 AliMUONResponseFactory.cxx:23
 AliMUONResponseFactory.cxx:24
 AliMUONResponseFactory.cxx:25
 AliMUONResponseFactory.cxx:26
 AliMUONResponseFactory.cxx:27
 AliMUONResponseFactory.cxx:28
 AliMUONResponseFactory.cxx:29
 AliMUONResponseFactory.cxx:30
 AliMUONResponseFactory.cxx:31
 AliMUONResponseFactory.cxx:32
 AliMUONResponseFactory.cxx:33
 AliMUONResponseFactory.cxx:34
 AliMUONResponseFactory.cxx:35
 AliMUONResponseFactory.cxx:36
 AliMUONResponseFactory.cxx:37
 AliMUONResponseFactory.cxx:38
 AliMUONResponseFactory.cxx:39
 AliMUONResponseFactory.cxx:40
 AliMUONResponseFactory.cxx:41
 AliMUONResponseFactory.cxx:42
 AliMUONResponseFactory.cxx:43
 AliMUONResponseFactory.cxx:44
 AliMUONResponseFactory.cxx:45
 AliMUONResponseFactory.cxx:46
 AliMUONResponseFactory.cxx:47
 AliMUONResponseFactory.cxx:48
 AliMUONResponseFactory.cxx:49
 AliMUONResponseFactory.cxx:50
 AliMUONResponseFactory.cxx:51
 AliMUONResponseFactory.cxx:52
 AliMUONResponseFactory.cxx:53
 AliMUONResponseFactory.cxx:54
 AliMUONResponseFactory.cxx:55
 AliMUONResponseFactory.cxx:56
 AliMUONResponseFactory.cxx:57
 AliMUONResponseFactory.cxx:58
 AliMUONResponseFactory.cxx:59
 AliMUONResponseFactory.cxx:60
 AliMUONResponseFactory.cxx:61
 AliMUONResponseFactory.cxx:62
 AliMUONResponseFactory.cxx:63
 AliMUONResponseFactory.cxx:64
 AliMUONResponseFactory.cxx:65
 AliMUONResponseFactory.cxx:66
 AliMUONResponseFactory.cxx:67
 AliMUONResponseFactory.cxx:68
 AliMUONResponseFactory.cxx:69
 AliMUONResponseFactory.cxx:70
 AliMUONResponseFactory.cxx:71
 AliMUONResponseFactory.cxx:72
 AliMUONResponseFactory.cxx:73
 AliMUONResponseFactory.cxx:74
 AliMUONResponseFactory.cxx:75
 AliMUONResponseFactory.cxx:76
 AliMUONResponseFactory.cxx:77
 AliMUONResponseFactory.cxx:78
 AliMUONResponseFactory.cxx:79
 AliMUONResponseFactory.cxx:80
 AliMUONResponseFactory.cxx:81
 AliMUONResponseFactory.cxx:82
 AliMUONResponseFactory.cxx:83
 AliMUONResponseFactory.cxx:84
 AliMUONResponseFactory.cxx:85
 AliMUONResponseFactory.cxx:86
 AliMUONResponseFactory.cxx:87
 AliMUONResponseFactory.cxx:88
 AliMUONResponseFactory.cxx:89
 AliMUONResponseFactory.cxx:90
 AliMUONResponseFactory.cxx:91
 AliMUONResponseFactory.cxx:92
 AliMUONResponseFactory.cxx:93
 AliMUONResponseFactory.cxx:94
 AliMUONResponseFactory.cxx:95
 AliMUONResponseFactory.cxx:96
 AliMUONResponseFactory.cxx:97
 AliMUONResponseFactory.cxx:98
 AliMUONResponseFactory.cxx:99
 AliMUONResponseFactory.cxx:100
 AliMUONResponseFactory.cxx:101
 AliMUONResponseFactory.cxx:102
 AliMUONResponseFactory.cxx:103
 AliMUONResponseFactory.cxx:104
 AliMUONResponseFactory.cxx:105
 AliMUONResponseFactory.cxx:106
 AliMUONResponseFactory.cxx:107
 AliMUONResponseFactory.cxx:108
 AliMUONResponseFactory.cxx:109
 AliMUONResponseFactory.cxx:110
 AliMUONResponseFactory.cxx:111
 AliMUONResponseFactory.cxx:112
 AliMUONResponseFactory.cxx:113
 AliMUONResponseFactory.cxx:114
 AliMUONResponseFactory.cxx:115
 AliMUONResponseFactory.cxx:116
 AliMUONResponseFactory.cxx:117
 AliMUONResponseFactory.cxx:118
 AliMUONResponseFactory.cxx:119
 AliMUONResponseFactory.cxx:120
 AliMUONResponseFactory.cxx:121
 AliMUONResponseFactory.cxx:122
 AliMUONResponseFactory.cxx:123
 AliMUONResponseFactory.cxx:124
 AliMUONResponseFactory.cxx:125
 AliMUONResponseFactory.cxx:126
 AliMUONResponseFactory.cxx:127
 AliMUONResponseFactory.cxx:128
 AliMUONResponseFactory.cxx:129
 AliMUONResponseFactory.cxx:130
 AliMUONResponseFactory.cxx:131
 AliMUONResponseFactory.cxx:132
 AliMUONResponseFactory.cxx:133
 AliMUONResponseFactory.cxx:134
 AliMUONResponseFactory.cxx:135
 AliMUONResponseFactory.cxx:136
 AliMUONResponseFactory.cxx:137
 AliMUONResponseFactory.cxx:138
 AliMUONResponseFactory.cxx:139
 AliMUONResponseFactory.cxx:140
 AliMUONResponseFactory.cxx:141
 AliMUONResponseFactory.cxx:142
 AliMUONResponseFactory.cxx:143
 AliMUONResponseFactory.cxx:144
 AliMUONResponseFactory.cxx:145
 AliMUONResponseFactory.cxx:146
 AliMUONResponseFactory.cxx:147
 AliMUONResponseFactory.cxx:148
 AliMUONResponseFactory.cxx:149
 AliMUONResponseFactory.cxx:150
 AliMUONResponseFactory.cxx:151
 AliMUONResponseFactory.cxx:152
 AliMUONResponseFactory.cxx:153
 AliMUONResponseFactory.cxx:154
 AliMUONResponseFactory.cxx:155
 AliMUONResponseFactory.cxx:156
 AliMUONResponseFactory.cxx:157
 AliMUONResponseFactory.cxx:158
 AliMUONResponseFactory.cxx:159
 AliMUONResponseFactory.cxx:160
 AliMUONResponseFactory.cxx:161
 AliMUONResponseFactory.cxx:162
 AliMUONResponseFactory.cxx:163
 AliMUONResponseFactory.cxx:164
 AliMUONResponseFactory.cxx:165
 AliMUONResponseFactory.cxx:166
 AliMUONResponseFactory.cxx:167
 AliMUONResponseFactory.cxx:168
 AliMUONResponseFactory.cxx:169
 AliMUONResponseFactory.cxx:170
 AliMUONResponseFactory.cxx:171
 AliMUONResponseFactory.cxx:172
 AliMUONResponseFactory.cxx:173
 AliMUONResponseFactory.cxx:174
 AliMUONResponseFactory.cxx:175
 AliMUONResponseFactory.cxx:176
 AliMUONResponseFactory.cxx:177
 AliMUONResponseFactory.cxx:178
 AliMUONResponseFactory.cxx:179
 AliMUONResponseFactory.cxx:180
 AliMUONResponseFactory.cxx:181
 AliMUONResponseFactory.cxx:182
 AliMUONResponseFactory.cxx:183
 AliMUONResponseFactory.cxx:184
 AliMUONResponseFactory.cxx:185
 AliMUONResponseFactory.cxx:186
 AliMUONResponseFactory.cxx:187
 AliMUONResponseFactory.cxx:188
 AliMUONResponseFactory.cxx:189
 AliMUONResponseFactory.cxx:190
 AliMUONResponseFactory.cxx:191
 AliMUONResponseFactory.cxx:192
 AliMUONResponseFactory.cxx:193
 AliMUONResponseFactory.cxx:194
 AliMUONResponseFactory.cxx:195
 AliMUONResponseFactory.cxx:196
 AliMUONResponseFactory.cxx:197
 AliMUONResponseFactory.cxx:198
 AliMUONResponseFactory.cxx:199
 AliMUONResponseFactory.cxx:200
 AliMUONResponseFactory.cxx:201
 AliMUONResponseFactory.cxx:202
 AliMUONResponseFactory.cxx:203
 AliMUONResponseFactory.cxx:204
 AliMUONResponseFactory.cxx:205
 AliMUONResponseFactory.cxx:206
 AliMUONResponseFactory.cxx:207
 AliMUONResponseFactory.cxx:208
 AliMUONResponseFactory.cxx:209
 AliMUONResponseFactory.cxx:210
 AliMUONResponseFactory.cxx:211
 AliMUONResponseFactory.cxx:212
 AliMUONResponseFactory.cxx:213
 AliMUONResponseFactory.cxx:214
 AliMUONResponseFactory.cxx:215
 AliMUONResponseFactory.cxx:216
 AliMUONResponseFactory.cxx:217
 AliMUONResponseFactory.cxx:218
 AliMUONResponseFactory.cxx:219
 AliMUONResponseFactory.cxx:220
 AliMUONResponseFactory.cxx:221
 AliMUONResponseFactory.cxx:222
 AliMUONResponseFactory.cxx:223
 AliMUONResponseFactory.cxx:224
 AliMUONResponseFactory.cxx:225
 AliMUONResponseFactory.cxx:226
 AliMUONResponseFactory.cxx:227
 AliMUONResponseFactory.cxx:228
 AliMUONResponseFactory.cxx:229
 AliMUONResponseFactory.cxx:230
 AliMUONResponseFactory.cxx:231
 AliMUONResponseFactory.cxx:232
 AliMUONResponseFactory.cxx:233
 AliMUONResponseFactory.cxx:234
 AliMUONResponseFactory.cxx:235
 AliMUONResponseFactory.cxx:236
 AliMUONResponseFactory.cxx:237