// Response class for station 1 including electronics and detector response.
// Individual pedestals or noise levels can be controlled separately.
// The current pulse height responses do not contain any physics
-
-#include <vector>
+// Included in AliRoot 2003/01/28
#include <TMath.h>
#include <TRandom.h>
#include <Riostream.h>
#include "AliMpIntPair.h"
-#include "AliMpPlaneSegmentation.h"
+#include "AliMpSectorSegmentation.h"
#include "AliMpPad.h"
#include "AliMpMotifMap.h"
#include "AliMpSector.h"
-#include "AliMpPlane.h"
#include "AliMpZone.h"
#include "AliMpSubZone.h"
#include "AliMpVRowSegment.h"
#include "AliMUONSt1IniReader.h"
#include "AliMUONSt1Decoder.h"
#include "AliMUONTransientDigit.h"
+#include "AliMUONSegmentation.h"
+#include "AliMUONGeometrySegmentation.h"
+#include "AliMUONSt12QuadrantSegmentation.h"
+#include "AliMUON.h"
+#include "AliRun.h"
+#include "AliLog.h"
-ClassImp(AliMUONSt1Response);
+ClassImp(AliMUONSt1Response)
const TString AliMUONSt1Response::fgkTopDir = getenv("ALICE_ROOT");
const TString AliMUONSt1Response::fgkDataDir = "/MUON/data/";
//__________________________________________________________________________
-AliMUONSt1Response::AliMUONSt1Response(Int_t chamber)
+AliMUONSt1Response::AliMUONSt1Response(Int_t chamberId)
: AliMUONResponseV0(),
+ fReadFiles(kTRUE),
fCountNofCalls(0),
fCountUnknownZone(0),
fCountUnknownIndices(0),
- fChamber(chamber),
+ fChamberId(chamberId),
fParams(),
fRegions(),
fTrashList()
Int_t i;
for (i=0;i<2;i++){
fIniFileName[i]="";
- fPlane[0]=0;
- fPlaneSegmentation[i]=0;
+ for (Int_t j=0;j<fgkNofZones;j++)
+ {
+ fDefaultParameters[i][j]=0;
+ }
+ }
+ fTrashList.SetOwner(kTRUE);
+}
+
+
+//__________________________________________________________________________
+AliMUONSt1Response::AliMUONSt1Response()
+ : AliMUONResponseV0(),
+ fReadFiles(kTRUE),
+ fCountNofCalls(0),
+ fCountUnknownZone(0),
+ fCountUnknownIndices(0),
+ fChamberId(0),
+ fParams(),
+ fRegions(),
+ fTrashList()
+
+{
+// Standard constructor
+
+ Int_t i;
+ for (i=0;i<2;i++){
+ fIniFileName[i]="";
for (Int_t j=0;j<fgkNofZones;j++)
{
fDefaultParameters[i][j]=0;
{
// Copy constructor
- Fatal("Copy constructor",
- "Copy constructor is not implemented.");
+ AliFatal("Copy constructor is not implemented.");
}
//__________________________________________________________________________
//destructor
Int_t i;
for (i=0;i<2;i++){
- if (fPlaneSegmentation[i]) delete fPlaneSegmentation[i];
- if (fPlane[i]) delete fPlane[i];
fTrashList.Delete();
}
}
// check assignement to self
if (this == &rhs) return *this;
- Fatal("operator=",
- "Assignment operator is not implemented.");
+ AliFatal("Assignment operator is not implemented.");
return *this;
}
//__________________________________________________________________________
-void AliMUONSt1Response::ReadCouplesOfIntRanges(const string& value,TList* list,AliMUONSt1ElectronicElement::TDescription descr)
+const AliMUONGeometrySegmentation*
+AliMUONSt1Response::GetGeometrySegmentation(Int_t cathod)
+{
+// Get geometry segmentation for given cathod plane
+
+ AliMUON* muon = (AliMUON*)gAlice->GetModule("MUON");
+ AliMUONGeometrySegmentation* segmentation
+ = muon->GetSegmentation()->GetModuleSegmentation(fChamberId, cathod-1);
+
+ if (!segmentation)
+ AliFatal(Form("Geometry segmentation for cathod %d not defined.", cathod));
+
+ return segmentation;
+}
+
+//__________________________________________________________________________
+const AliMpSectorSegmentation*
+AliMUONSt1Response::GetMpSegmentation(Int_t detElemId, Int_t cathod)
+{
+// Get mapping segmentation for given detection elemnt
+
+ const AliMUONVGeometryDESegmentation* deSegmentation
+ = GetGeometrySegmentation(cathod)->GetDESegmentation(detElemId);
+
+ if (!deSegmentation) {
+ AliFatal(Form("DE segmentation for detElemId= %d not defined.",
+ detElemId));
+ }
+
+ return (const AliMpSectorSegmentation*)deSegmentation->GetMpSegmentation();
+ // check if we need AliMpSectorSegmentation
+}
+
+
+//__________________________________________________________________________
+void AliMUONSt1Response::ReadCouplesOfIntRanges(const string& value,
+ TList* list,
+ AliMUONSt1ElectronicElement::TDescription descr)
{
// Decode couplets of integer ranges (enclosed within parenthesis and
// separated by a comma, eg. (12/20,33/60) for ranges 12 to 20 and 33 to 60)
// and save these ranges in <list>
- vector<string> lstCpl = decoder::SplitNtuples(value);
- for (unsigned int n=0;n<lstCpl.size();n++){ // for each (..,..) couplet
- vector<string> lst = decoder::SplitList(lstCpl[n],",");
+
+ StringVector lstCpl = decoder::SplitNtuples(value);
+ for (UInt_t n=0;n<lstCpl.size();n++){ // for each (..,..) couplet
+ StringVector lst = decoder::SplitList(lstCpl[n],",");
// should have 2 elements
if (lst.size() != 2) {
- Warning("ReadIniFile","Bad pad definition");
+ AliWarning("Bad pad definition");
continue;
}
- vector<pair <int,int> > lst1 = decoder::DecodeListOfIntRanges(lst[0],";");
- vector<pair <int,int> > lst2 = decoder::DecodeListOfIntRanges(lst[1],";");
- for (unsigned int u1=0;u1<lst1.size();u1++){
- for (unsigned int u2=0;u2<lst2.size();u2++){
+ IntPairVector lst1 = decoder::DecodeListOfIntRanges(lst[0],";");
+ IntPairVector lst2 = decoder::DecodeListOfIntRanges(lst[1],";");
+ for (UInt_t u1=0;u1<lst1.size();u1++){
+ for (UInt_t u2=0;u2<lst2.size();u2++){
AliMUONSt1ElectronicElement* elem
= new AliMUONSt1ElectronicElement(descr);
fTrashList.Add(elem);
//__________________________________________________________________________
-void AliMUONSt1Response::ReadCouplesOfFloatRanges(const string& value,TList* list)
+void AliMUONSt1Response::ReadCouplesOfFloatRanges(const string& value,
+ TList* list)
{
// Decode couplets of floating point ranges (enclosed within parenthesis and
// separated by a comma, eg. (12./20.,33./60.) for ranges 12. to 20. and 33. to 60.)
// and save these ranges in <list>
- vector<string> lstCpl = decoder::SplitNtuples(value);
- for (unsigned int n=0;n<lstCpl.size();n++){ // for each (..,..) couplets
- vector<string> lst = decoder::SplitList(lstCpl[n],",");
+
+ StringVector lstCpl = decoder::SplitNtuples(value);
+ for (UInt_t n=0;n<lstCpl.size();n++){ // for each (..,..) couplets
+ StringVector lst = decoder::SplitList(lstCpl[n],",");
// should have 2 elements
if (lst.size() != 2) {
- Warning("ReadIniFile","Bad pad definition");
+ AliWarning("Bad pad definition");
continue;
}
- vector<pair <double,double> > lst1 = decoder::DecodeListOfFloatRanges(lst[0],";");
- vector<pair <double,double> > lst2 = decoder::DecodeListOfFloatRanges(lst[1],";");
- for (unsigned int u1=0;u1<lst1.size();u1++){
- for (unsigned int u2=0;u2<lst2.size();u2++){
+ DoublePairVector lst1 = decoder::DecodeListOfFloatRanges(lst[0],";");
+ DoublePairVector lst2 = decoder::DecodeListOfFloatRanges(lst[1],";");
+ for (UInt_t u1=0;u1<lst1.size();u1++){
+ for (UInt_t u2=0;u2<lst2.size();u2++){
AliMUONSt1ElectronicElement* elem
= new AliMUONSt1ElectronicElement(AliMUONSt1ElectronicElement::kXY);
fTrashList.Add(elem);
//__________________________________________________________________________
-void AliMUONSt1Response::SetPairToParam(const string& name,const string& value,AliMUONSt1ResponseParameter* param) const
+void AliMUONSt1Response::SetPairToParam(const string& name, const string& value,
+ AliMUONSt1ResponseParameter* param) const
{
// set a (name,value) pair to <param>
+
TString path = fgkTopDir + fgkDataDir ;
const char* nm = name.c_str();
if (fgkStateName.CompareTo(nm,TString::kIgnoreCase)==0){
param->SetState(atoi(value.c_str()));
} else if (fgkPedestalName.CompareTo(nm,TString::kIgnoreCase)==0){
- vector<string> lst = decoder::SplitList(value," ");
+ StringVector lst = decoder::SplitList(value," ");
if ((lst.size()>0) && (fgkNotName.CompareTo(lst[0].c_str(),TString::kIgnoreCase)==0)){
param->UnSetPedestal();
} else if ((lst.size()>1) && (fgkValueName.CompareTo(lst[0].c_str(),TString::kIgnoreCase)==0)){
param->SetPedestal(atof(lst[1].c_str()),atof(lst[2].c_str()));
}
} else if (fgkNoiseName.CompareTo(nm,TString::kIgnoreCase)==0){
- vector<string> lst = decoder::SplitList(value," ");
+ StringVector lst = decoder::SplitList(value," ");
if ((lst.size()>1) && (fgkValueName.CompareTo(lst[0].c_str(),TString::kIgnoreCase)==0)){
param->SetNoise(atof(lst[1].c_str()));
} else if ((lst.size()>1) && (fgkFileName.CompareTo(lst[0].c_str(),TString::kIgnoreCase)==0)){
} else if (fgkNofSigmaName.CompareTo(nm,TString::kIgnoreCase)==0){
param->SetNofSigma(atoi(value.c_str()));
} else if (fgkStickyOnName.CompareTo(nm,TString::kIgnoreCase)==0){
- vector< pair<int,int> > lst = decoder::DecodeListOfIntRanges(value);
- for (unsigned int i=0;i<lst.size();i++){
- for (int j=lst[i].first;(j<12) && (j<=lst[i].second);j++){
+ IntPairVector lst = decoder::DecodeListOfIntRanges(value);
+ for (UInt_t i=0;i<lst.size();i++){
+ for (Int_t j=lst[i].first;(j<12) && (j<=lst[i].second);j++){
param->SetStickyBitOn(j);
}
}
} else if (fgkStickyOffName.CompareTo(nm,TString::kIgnoreCase)==0){
- vector< pair<int,int> > lst = decoder::DecodeListOfIntRanges(value);
- for (unsigned int i=0;i<lst.size();i++){
- for (int j=lst[i].first;(j<12) && (j<=lst[i].second);j++){
+ IntPairVector lst = decoder::DecodeListOfIntRanges(value);
+ for (UInt_t i=0;i<lst.size();i++){
+ for (Int_t j=lst[i].first;(j<12) && (j<=lst[i].second);j++){
param->SetStickyBitOff(j);
}
}
//__________________________________________________________________________
-void AliMUONSt1Response::SetPairToListElem(const string& name,const string& value,TList* list)
+void AliMUONSt1Response::SetPairToListElem(const string& name,
+ const string& value, TList* list)
{
// set a (name,value) pair to <list>
+
const char* nm = name.c_str();
if (fgkIJName.CompareTo(nm,TString::kIgnoreCase)==0){
ReadCouplesOfIntRanges(value,list,AliMUONSt1ElectronicElement::kIJ);
} else if (fgkMGName.CompareTo(nm,TString::kIgnoreCase)==0){
ReadCouplesOfIntRanges(value,list,AliMUONSt1ElectronicElement::kMG);
} else if (fgkMName.CompareTo(nm,TString::kIgnoreCase)==0){
- vector< pair<int,int> > lst = decoder::DecodeListOfIntRanges(value);
- for (unsigned int i=0;i<lst.size();i++){
+ IntPairVector lst = decoder::DecodeListOfIntRanges(value);
+ for (UInt_t i=0;i<lst.size();i++){
AliMUONSt1ElectronicElement* elem
= new AliMUONSt1ElectronicElement(AliMUONSt1ElectronicElement::kM);
fTrashList.Add(elem);
void AliMUONSt1Response::ReadIniFile(Int_t plane)
{
//Read the ini file and fill the <plane>th structures
+
+ cout << "ReadIniFile now ..." << endl;
+
TString path = fgkTopDir + fgkDataDir ;
//read .ini file
if (gSystem->AccessPathName(path+fIniFileName[plane],kReadPermission)){
- Fatal("ReadIniFile",
- Form("Unable to Read the file %s",fIniFileName[plane].Data()));
+ AliFatal(Form("Unable to Read the file %s",fIniFileName[plane].Data()));
return;
}
fRegions.clear();
//__________________________________________________________________________
void AliMUONSt1Response::ReadIniFile(Int_t plane,const TString& fileName,
- Bool_t rdParam,Bool_t rdRegion,Bool_t rdRule)
+ Bool_t rdParam,Bool_t rdRegion,Bool_t rdRule)
{
//Read the given ini file and fill the <plane>th structures
+
cout<<"Reading parameter file "<<fileName<<endl;
AliMUONSt1IniReader iniFile(fileName.Data());
- AliMUONSt1IniReader::TChapter chap;
- AliMUONSt1IniReader::TValueList vals;
- AliMUONSt1IniReader::TValueList::iterator itValue;
+ AliMUONSt1IniReader::Chapter chap;
+ AliMUONSt1IniReader::ValueList vals;
+ AliMUONSt1IniReader::ValueList::iterator itValue;
while (!iniFile.Eof()){
chap = iniFile.MakeCurrentChapter();
TString chapName = chap.first.c_str();
string name = (*itValue).first;
string value = (*itValue).second;
if (fgkIncludeName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){
- vector<string> lst = decoder::SplitList(value,":");
+ StringVector lst = decoder::SplitList(value,":");
if (lst.size()>0){
TString inFileName = TString(gSystem->DirName(fileName))+"/" + lst[0].c_str();
Bool_t inParam=kFALSE,inRegion=kFALSE,inRule=kFALSE;
if (lst.size()>1) {
- vector<string> lst2 = decoder::SplitList(lst[1],",");
- for (unsigned int k=0;k<lst2.size();k++){
+ StringVector lst2 = decoder::SplitList(lst[1],",");
+ for (UInt_t k=0;k<lst2.size();k++){
if (fgkParameterName.CompareTo(lst2[k].c_str(),TString::kIgnoreCase)==0){
inParam=kTRUE;
} else if (fgkRegionName.CompareTo(lst2[k].c_str(),TString::kIgnoreCase)==0){
string name = (*itValue).first;
string value = (*itValue).second;
if (fgkZoneName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){
- vector< pair<int,int> > lst = decoder::DecodeListOfIntRanges(value);
- for (unsigned int i=0;i<lst.size();i++){
- for (int j=lst[i].first;(j<=fgkNofZones) && (j<=lst[i].second);j++) {
+ IntPairVector lst = decoder::DecodeListOfIntRanges(value);
+ for (UInt_t i=0;i<lst.size();i++){
+ for (Int_t j=lst[i].first;(j<=fgkNofZones) && (j<=lst[i].second);j++) {
if (j>0) zones[j-1] = kTRUE;
}
}
} else if (fgkRegionName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){
- TListMap::iterator it = fRegions.find(value);
+ ListMap::iterator it = fRegions.find(value);
if (it != fRegions.end()){
if (!rule) {
rule = new AliMUONSt1ResponseRule();
while ((el = static_cast<AliMUONSt1ElectronicElement*>(next()))){
rule->AddElement(el);
}
- } else Warning("ReadIniFile",Form("Can't find region named %s",value.c_str()));
+ } else AliWarning(Form("Can't find region named %s",value.c_str()));
}
}
for (itValue = vals.begin() ; itValue != vals.end(); ++itValue){
string name = (*itValue).first;
string value = (*itValue).second;
if (fgkParameterName.CompareTo(name.c_str(),TString::kIgnoreCase)==0){
- TParamsMap::iterator it = fParams.find(value);
+ ParamsMap::iterator it = fParams.find(value);
if (it != fParams.end()){
AliMUONSt1ResponseParameter* param = (*it).second;
for (i=0;i<fgkNofZones;i++) if (zones[i]) {
fDefaultParameters[plane][i]=param;
}
if (rule) rule->AddParameter(param);
- } else Warning("ReadIniFile",Form("Can't find parameter named %s",value.c_str()));
+ } else AliWarning(Form("Can't find parameter named %s",value.c_str()));
}
}
if (rule) fRulesList[plane].AddFirst(rule);
}
}
- for (TListMap::iterator it = fRegions.begin() ; it != fRegions.end(); ++it) delete (*it).second;
+ for (ListMap::iterator it = fRegions.begin() ; it != fRegions.end(); ++it) delete (*it).second;
}
{
// Define the current response rules with respect to the description
// given in the "configChamber1.ini" and "configChamber2.ini" files.
+
Int_t i;
TString path = fgkTopDir + fgkDataDir ;
- TString configFileName = path + fgkConfigBaseName + Form("%d.ini",fChamber);
+ TString configFileName = path + fgkConfigBaseName + Form("%d.ini",fChamberId);
if (gSystem->AccessPathName(configFileName,kReadPermission)){
// no configChamberI.ini file exists
SetIniFileName(0,fgkStandardIniFileName);
}
}
//book memory and fill them with .ini files
- fPlane[0]=AliMpPlane::Create(kStation1, kBendingPlane);
- fPlane[1]=AliMpPlane::Create(kStation1, kNonBendingPlane);
for (i=0;i<2;i++){
- fPlaneSegmentation[i]= new AliMpPlaneSegmentation(fPlane[i]);
ReadIniFile(i);
}
+
+ fReadFiles = kFALSE;
}
//__________________________________________________________________________
Float_t AliMUONSt1Response::IntPH(Float_t eloss)
{
// Calculate charge from given ionization energy lost.
+
Int_t nel;
nel= Int_t(eloss*1.e9/20);
Float_t charge=0;
//__________________________________________________________________________
-AliMpZone* AliMUONSt1Response::FindZone(AliMpSector* sector,Int_t posId) const
+AliMpZone* AliMUONSt1Response::FindZone(const AliMpSector* sector, Int_t posId) const
{
// to be moved to AliMpSector::
+
for (Int_t izone=1;izone<=sector->GetNofZones();izone++){
AliMpZone* zone = sector->GetZone(izone);
for (Int_t isub=0;isub<zone->GetNofSubZones();isub++){
//__________________________________________________________________________
-
-Int_t AliMUONSt1Response::DigitResponse(Int_t digit,AliMUONTransientDigit* where)
+Int_t AliMUONSt1Response::DigitResponse(Int_t digit, AliMUONTransientDigit* where)
{
// returns the electronic response of pad located at <where>, when
// a charge <digit> is present
// <<" on plane "<<where->Cathode()<<endl;
//read the files the first time this function is called
- if (!fPlane[0]) ReadFiles();
+ if (fReadFiles) ReadFiles();
fCountNofCalls++;
+ const AliMpSectorSegmentation* segmentation
+ = GetMpSegmentation(where->DetElemId(), where->Cathode());
+ const AliMpSector* sector = segmentation->GetSector();
+
AliMpIntPair indices(where->PadX(),where->PadY());
- AliMpPad pad = fPlaneSegmentation[where->Cathode()]->PadByIndices(indices,kFALSE);
+ AliMpPad pad = segmentation->PadByIndices(indices,kFALSE);
Int_t gc=0;
Int_t numZone=0;
AliMpZone* zone=0;
+ cout << "Digit: DE=" << where->DetElemId()
+ << " cathod=" << where->Cathode() << endl;
+ cout << "Found pad: " << pad << endl;
if (pad.IsValid()) {
AliMpIntPair location = pad.GetLocation();
//cout<<location.GetFirst()<<endl;
Int_t posId=abs(location.GetFirst());
+/*
AliMpSector* sector=0;
if (fPlane[0]->GetFrontSector()->GetMotifMap()->FindMotifPosition(posId))
sector=(AliMpSector*)fPlane[0]->GetFrontSector();
else if (fPlane[0]->GetBackSector()->GetMotifMap()->FindMotifPosition(posId))
sector=(AliMpSector*)fPlane[0]->GetBackSector();
-
+*/
if (sector) zone=FindZone(sector,posId);
if (zone){
numZone=zone->GetID()-1;
fCountUnknownIndices++;
}
+ cout << "Zone: " << zone << endl;
+
if (!zone) {
cout<<"Probleme electronic of pad "<<where->PadX()<<' '<<where->PadY()
<<" on plane "<<where->Cathode()<<endl;
return 6666;
}
+ cout << "Loop1: " << endl;
TList listParams;
- TIter next(&fRulesList[where->Cathode()]);
+ TIter next(&fRulesList[where->Cathode()-1]);
AliMUONSt1ResponseRule* rule;
while ( (rule = static_cast<AliMUONSt1ResponseRule*>(next())))
if (rule->Contains(pad)) listParams.AddAll(rule->GetParameters());
- if (fDefaultParameters[where->Cathode()][numZone])
- listParams.Add(fDefaultParameters[where->Cathode()][numZone]);
+ if (fDefaultParameters[where->Cathode()-1][numZone])
+ listParams.Add(fDefaultParameters[where->Cathode()-1][numZone]);
+ cout << "Loop2: " << endl;
AliMUONSt1ResponseParameter* param;
TIter nextParam(&listParams);
while ( (param = static_cast<AliMUONSt1ResponseParameter*>(nextParam()))){
return 0;
}
}
+ cout << "Loop3: " << endl;
nextParam.Reset();
while ( (param = static_cast<AliMUONSt1ResponseParameter*>(nextParam()))){
if (param->HasPedestal()) {
void AliMUONSt1Response::PrintStatistics() const
{
// Show the results of the statistics
+
cout<<"The DigitResponse() method was called "<<fCountNofCalls<<" times"<<endl;
cout<<" it was unable to find the pad corresponding to the given indices "
<<fCountUnknownIndices<<" times ("