Commit b70bbf1a authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Adding the event:data:crystal and event:data:ccrystal in TreeBuilder

parent 27020b00
......@@ -39,6 +39,8 @@ Frame: Agata data:ranc2 4 0 Agata data:ranc2 65000 0
Frame: Agata data:psa 4 0 Agata data:psa 0 0
Frame: Agata data:tracked 4 0 Agata data:tracked 1 0
Frame: Agata event:data 4 0 Agata event:data 4 0
Frame: Agata event:data:crystal 4 0 Agata event:data:crystal 4 0
Frame: Agata event:data:ccrystal 4 0 Agata event:data:ccrystal 4 0
Frame: Agata event:data:psa 4 0 Agata event:data:psa 4 0
Frame: Agata event:data:ranc0 4 0 Agata event:data:ranc0 4 0
Frame: Agata event:data:ranc1 4 0 Agata event:data:ranc1 4 0
......
......@@ -43,6 +43,18 @@ TB_AGATA_CRYSTAL::~TB_AGATA_CRYSTAL()
void TB_AGATA_CRYSTAL::Init()
{
if(fTriggerName.Contains("ccrystal")) {
fTraceLenght = kCCrystalTraceLenght;
fType = ccrystal;
}
else if(fTriggerName.Contains("crystal")) {
fTraceLenght = kCrystalTraceLenght;
fType = crystal;
}
else {
fTraceLenght = kMaxTraceLenght;
fType = undef;
}
}
void TB_AGATA_CRYSTAL::InitValues()
......@@ -54,8 +66,14 @@ void TB_AGATA_CRYSTAL::InitValues()
crystalTS = 0;
crystalId = 0;
memset(SegmentTraces, 0, sizeof(SegmentTraces));
memset(CoreTraces, 0, sizeof(CoreTraces));
if(fType == crystal) {
memset(SegTracesu, 0, sizeof(SegTracesu));
memset(CoreTracesu, 0, sizeof(CoreTracesu));
}
else if(fType == ccrystal) {
memset(SegTraces, 0, sizeof(SegTraces));
memset(CoreTraces, 0, sizeof(CoreTraces));
}
memset(SegE, 0, sizeof(SegE));
memset(CoreE, 0, sizeof(CoreE));
}
......@@ -70,13 +88,19 @@ void TB_AGATA_CRYSTAL::InitTree()
if(fTree == nullptr)
return;
fTree->Branch("segTraces", SegmentTraces, Form("segTraces[%d]/F",kNSG*kNSamples));
fTree->Branch("coreTraces", CoreTraces, Form("coreTraces[%d]/F",kNCC*kNSamples));
fTree->Branch("segE", SegE, Form("segE[%d]/F",kNSG));
fTree->Branch("coreE", CoreE, Form("coreE[%d]/F",kNCC));
if(fType == crystal) {
fTree->Branch("SegTraces", SegTracesu, Form("SegTraces[%d]/S",kNSG*fTraceLenght));
fTree->Branch("CoreTraces", CoreTracesu, Form("CoreTraces[%d]/S",kNCC*fTraceLenght));
}
else if(fType == ccrystal){
fTree->Branch("SegTraces", SegTraces, Form("SegTraces[%d]/F",kNSG*fTraceLenght));
fTree->Branch("CoreTraces", CoreTraces, Form("CoreTraces[%d]/F",kNCC*fTraceLenght));
}
fTree->Branch("SegE", SegE, Form("SegE[%d]/F",kNSG));
fTree->Branch("CoreE", CoreE, Form("CoreE[%d]/F",kNCC));
fTree->Branch("crystalId", &crystalId, "crystalId/I");
fTree->Branch("crystalTS", &crystalTS, "crystalTS/l");
fTree->Branch("CrystalId", &crystalId, "CrystalId/I");
fTree->Branch("CrystalTS", &crystalTS, "CrystalTS/l");
}
void TB_AGATA_CRYSTAL::Process(Int_t idet)
......@@ -93,18 +117,26 @@ void TB_AGATA_CRYSTAL::Process(Int_t idet)
crystalTS = ((AgataKey *)fSFrame->GetFrame()->GetKey())->GetTimeStamp();
crystalId = data->GetUID();
if(!WarnedDone && data->GetCore(0)->GetSignal()->GetLength()!=kNSamples) {
Log << error << " Signal length: " << data->GetCore(0)->GetSignal()->GetLength() << " ; Stored length in tree: " << kNSamples << nline;
if(!WarnedDone && data && data->GetCore(0)->GetSignal()->GetLength()!=fTraceLenght) {
Log << error << " Signal length: " << data->GetCore(0)->GetSignal()->GetLength() << " ; Stored length in tree: " << fTraceLenght << nline;
WarnedDone = true;
}
for (Int_t i = 0; i < kNCC; i++ ) {
memcpy(&CoreTraces[i*kNSamples],data->GetCore(i)->GetSignal()->Address(CoreTraces),sizeof(Float_t)*kNSamples);
if(fType==crystal)
memcpy(&CoreTracesu[i*fTraceLenght],data->GetCore(i)->GetSignal()->Address(CoreTracesu),sizeof(UShort_t)*fTraceLenght);
else if(fType == ccrystal)
memcpy(&CoreTraces[i*fTraceLenght],data->GetCore(i)->GetSignal()->Address(CoreTraces),sizeof(Float_t)*fTraceLenght);
CoreE[i] = data->GetCore(i)->GetE();
}
for (Int_t i = 0; i < kNSG; i++ ) {
memcpy(&SegmentTraces[i*kNSamples],data->GetSegment(i)->GetSignal()->Address(SegmentTraces),sizeof(Float_t)*kNSamples);
if(fType==crystal)
memcpy(&SegTracesu[i*fTraceLenght],data->GetSegment(i)->GetSignal()->Address(SegTracesu),sizeof(UShort_t)*fTraceLenght);
if(fType==ccrystal)
memcpy(&SegTraces[i*fTraceLenght],data->GetSegment(i)->GetSignal()->Address(SegTraces),sizeof(Float_t)*fTraceLenght);
SegE[i] = data->GetSegment(i)->GetE();
}
}
......@@ -222,25 +254,160 @@ void TB_AGATA_PSA::Process(Int_t idet)
}
}
/// ****** Builder ******///
/// ****** Builder CRYSTAL ******///
TB_AGATA_Builder_CRYSTAL::TB_AGATA_Builder_CRYSTAL(TString name, TString ADFKey) : TB_Detector(name,ADFKey)
{
gActualClass = "TB_AGATA_Builder_CRYSTAL";
}
TB_AGATA_Builder_CRYSTAL::~TB_AGATA_Builder_CRYSTAL()
{
}
void TB_AGATA_Builder_CRYSTAL::Init()
{
if(fTriggerName.Contains("ccrystal")) {
fSFrame = fTrigger->AddUtility("data:ccrystal",ConfAgent::theGlobalAgent());
fTraceLenght = kCCrystalTraceLenght;
fType = ccrystal;
}
else if(fTriggerName.Contains("crystal")){
fSFrame = fTrigger->AddUtility("data:crystal",ConfAgent::theGlobalAgent());
fTraceLenght = kCrystalTraceLenght;
fType = crystal;
}
else {
fTraceLenght = kMaxTraceLenght;
}
}
void TB_AGATA_Builder_CRYSTAL::InitValues()
{
Log.ClearMessage();
Log.GetProcessName() = gActualClass;
Log.SetProcessMethod("InitValues()");
nbCrystals = 0;
SegTracesSize = 0;
CoreTracesSize = 0;
SegESize = 0;
CoreESize = 0;
EvtCrystalTS = 0;
}
void TB_AGATA_Builder_CRYSTAL::InitTree()
{
Log.ClearMessage();
Log.GetProcessName() = gActualClass;
Log.SetProcessMethod("InitTree()");
if(fTree == nullptr)
return;
fTree->Branch("nbCrystals", &nbCrystals, "nbCrystals/I");
fTree->Branch("CrystalId", crystalId, "CrystalId[nbCrystals]/F");
fTree->Branch("CrystalTS", crystalTS, "CrystalTS[nbCrystals]/F");
fTree->Branch("SegTracesSize", &SegTracesSize, "SegTracesSize/I");
if(fType == crystal)
fTree->Branch("SegTraces", SegTracesu, "SegTraces[SegTracesSize]/S");
else if(fType == ccrystal)
fTree->Branch("SegTraces", SegTraces, "SegTraces[SegTracesSize]/F");
fTree->Branch("CoreTracesSize", &CoreTracesSize, "CoreTracesSize/I");
if(fType == crystal)
fTree->Branch("CoreTraces", CoreTracesu, "CoreTraces[CoreTracesSize]/S");
else if(fType == ccrystal)
fTree->Branch("CoreTraces", CoreTraces, "CoreTraces[CoreTracesSize]/F");
fTree->Branch("SegESize", &SegESize, "SegESize/I");
fTree->Branch("SegE", SegE, "SegE[SegESize]/F");
fTree->Branch("CoreESize", &CoreESize, "CoreESize/I");
fTree->Branch("CoreE", CoreE, "CoreE[CoreESize]/F");
fTree->Branch("EvtCrystalTS", &EvtCrystalTS, "EvtCrystalTS/l");
}
void TB_AGATA_Builder_CRYSTAL::Process(Int_t idet)
{
Log.ClearMessage();
Log.GetProcessName() = "TB_AGATA_Builder_CRYSTAL";
Log.SetProcessMethod(Form("Process(%d)",idet));
if(!fMergerMode)
fCompFrame = (AgataCompositeFrame*) fTrigger->GetInputSharedFP()->GetFrame();
else
fCompFrame = (AgataCompositeFrame*) fTrigger->GetInputSharedFP(idet+1)->GetFrame();
fCompFrame->Scan();
EvtCrystalTS = ((AgataKey *)fCompFrame->GetKey())->GetTimeStamp();
nbCrystals = fCompFrame->GetNbSubFrame();
CoreTracesSize = nbCrystals*kNCC*fTraceLenght;
CoreESize = nbCrystals*kNCC;
SegTracesSize = nbCrystals*kNSG*fTraceLenght;
SegESize = nbCrystals*kNSG;
for(Int_t i=0 ; i < nbCrystals ; i++) {
fCompFrame->LinkSubFrame(i,fSFrame->GetFrame());
fSFrame->GetFrame()->Read();
CrystalInterface *data = GetDataPointer<CrystalInterface>(fSFrame);
if(!WarnedDone && data && data->GetCore(0)->GetSignal()->GetLength()!=fTraceLenght) {
Log << error << " Signal length: " << data->GetCore(0)->GetSignal()->GetLength() << " ; Stored length in tree: " << fTraceLenght << nline;
WarnedDone = true;
}
crystalTS[i] = ((AgataKey *)fSFrame->GetFrame()->GetKey())->GetTimeStamp();
crystalId[i] = data->GetUID();
for (Int_t j = 0; j < kNCC; j++ ) {
if(fType==crystal)
memcpy(&CoreTracesu[i*fTraceLenght*kNCC+fTraceLenght*j],data->GetCore(j)->GetSignal()->Address(CoreTracesu),sizeof(UShort_t)*fTraceLenght);
else if(fType == ccrystal)
memcpy(&CoreTraces[i*fTraceLenght*kNCC+fTraceLenght*j],data->GetCore(j)->GetSignal()->Address(CoreTraces),sizeof(Float_t)*fTraceLenght);
CoreE[i*kNCC+j] = data->GetCore(j)->GetE();
}
for (Int_t j = 0; j < kNSG; j++ ) {
if(fType==crystal)
memcpy(&SegTracesu[i*fTraceLenght*kNSG+fTraceLenght*j],data->GetSegment(j)->GetSignal()->Address(SegTracesu),sizeof(UShort_t )*fTraceLenght);
else if(fType == ccrystal)
memcpy(&SegTraces[i*fTraceLenght*kNSG+fTraceLenght*j],data->GetSegment(j)->GetSignal()->Address(SegTraces),sizeof(Float_t)*fTraceLenght);
SegE[i*kNSG+j] = data->GetSegment(j)->GetE();
}
}
}
/// ****** Builder PSA ******///
TB_AGATA_Builder::TB_AGATA_Builder(TString name, TString ADFKey) : TB_Detector(name,ADFKey)
TB_AGATA_Builder_PSA::TB_AGATA_Builder_PSA(TString name, TString ADFKey) : TB_Detector(name,ADFKey)
{
gActualClass = "TB_AGATA_Builder";
gActualClass = "TB_AGATA_Builder_PSA";
}
TB_AGATA_Builder::~TB_AGATA_Builder()
TB_AGATA_Builder_PSA::~TB_AGATA_Builder_PSA()
{
}
void TB_AGATA_Builder::Init()
void TB_AGATA_Builder_PSA::Init()
{
fSFrame = fTrigger->AddUtility("data:psa",ConfAgent::theGlobalAgent());
ReadTransformation();
}
void TB_AGATA_Builder::InitValues()
void TB_AGATA_Builder_PSA::InitValues()
{
Log.ClearMessage();
Log.GetProcessName() = gActualClass;
......@@ -253,7 +420,7 @@ void TB_AGATA_Builder::InitValues()
}
void TB_AGATA_Builder::InitTree()
void TB_AGATA_Builder_PSA::InitTree()
{
Log.ClearMessage();
Log.GetProcessName() = gActualClass;
......@@ -350,7 +517,7 @@ void TB_AGATA_Builder::InitTree()
}
void TB_AGATA_Builder::Process(Int_t idet)
void TB_AGATA_Builder_PSA::Process(Int_t idet)
{
Log.ClearMessage();
Log.GetProcessName() = "TB_AGATA_Builder";
......
......@@ -35,11 +35,16 @@ protected:
static const int kNCC = ADF::CrystalInterface::kNbCores;
static const int kNSG = ADF::CrystalInterface::kNbSegments;
static const int kNSamples = 60;
static const int kMaxTraceLenght = 100;
static const int kCrystalTraceLenght = 100;
static const int kCCrystalTraceLenght = 60;
private:
Float_t SegmentTraces[kNSG*kNSamples];
Float_t CoreTraces[kNCC*kNSamples];
Float_t SegTraces[kNSG*kMaxTraceLenght];
UShort_t SegTracesu[kNSG*kMaxTraceLenght];
Float_t CoreTraces[kNCC*kMaxTraceLenght];
UShort_t CoreTracesu[kNCC*kMaxTraceLenght];
Float_t SegE[kNSG];
Float_t CoreE[kNCC];
......@@ -47,6 +52,8 @@ protected:
ULong64_t crystalId;
ULong64_t crystalTS;
Int_t fTraceLenght;
bool WarnedDone = false;
public:
......@@ -97,7 +104,56 @@ public:
/// ****** Builder ******///
class TB_AGATA_Builder : public TB_Detector
class TB_AGATA_Builder_CRYSTAL : public TB_Detector
{
protected:
static const int kNCC = ADF::CrystalInterface::kNbCores;
static const int kNSG = ADF::CrystalInterface::kNbSegments;
static const int kMaxTraceLenght = 100;
static const int kCrystalTraceLenght = 100;
static const int kCCrystalTraceLenght = 60;
protected:
static const Int_t MaxCore = 180; // Max number of cores in one event
Int_t nbCrystals; // for more than 1 frame (built event)
Int_t crystalId[MaxCore]; // for each crystal fired its ID
ULong64_t crystalTS[MaxCore]; // timestamp of cores
Int_t SegTracesSize;
Float_t SegTraces[kNSG*kMaxTraceLenght*MaxCore];
UShort_t SegTracesu[kNSG*kMaxTraceLenght*MaxCore];
Int_t CoreTracesSize;
Float_t CoreTraces[kNCC*kMaxTraceLenght*MaxCore];
UShort_t CoreTracesu[kNCC*kMaxTraceLenght*MaxCore];
Int_t SegESize;
Float_t SegE[kNSG*MaxCore];
Int_t CoreESize;
Float_t CoreE[kNCC*MaxCore];
ULong64_t EvtCrystalTS;
Int_t fTraceLenght;
bool WarnedDone = false;
public:
TB_AGATA_Builder_CRYSTAL(TString name="", TString ADFKey="");
virtual ~TB_AGATA_Builder_CRYSTAL();
void Init();
void InitValues();
void InitTree();
void Process(Int_t idet);
};
class TB_AGATA_Builder_PSA : public TB_Detector
{
struct core_property
{
......@@ -148,8 +204,8 @@ protected:
ULong64_t TSHit;
public:
TB_AGATA_Builder(TString name="", TString ADFKey="");
virtual ~TB_AGATA_Builder();
TB_AGATA_Builder_PSA(TString name="", TString ADFKey="");
virtual ~TB_AGATA_Builder_PSA();
void Init();
void InitValues();
......
......@@ -43,6 +43,10 @@ namespace AGAPRO {
class TB_Detector
{
protected:
enum kType { crystal, ccrystal, psa, ppsa, undef };
kType fType;
public:
std::string gMotherClass = "TB_Detector";
std::string gActualClass;
......
......@@ -382,13 +382,16 @@ void TreeBuilder::AddDetector(TString Name, TString ADFKey, Int_t MandatoryMode)
if(NameTest == "agata_crystal") {
det = new TB_AGATA_CRYSTAL(NameTest,ADFKey);
}
if(NameTest == "agata_psa") {
else if(NameTest == "agata_psa") {
det = new TB_AGATA_PSA(NameTest,ADFKey);
}
if(NameTest == "agata_builder") {
det = new TB_AGATA_Builder(NameTest,ADFKey);
else if(NameTest == "agata_builder" && ADFKey.Contains("crystal")) {
det = new TB_AGATA_Builder_CRYSTAL(NameTest,ADFKey);
}
if(NameTest == "agata_tracking") {
else if(NameTest == "agata_builder" && ADFKey.Contains("psa")) {
det = new TB_AGATA_Builder_PSA(NameTest,ADFKey);
}
else if(NameTest == "agata_tracking") {
det = new TB_AGATA_Tracking(NameTest,ADFKey);
}
else if(NameTest == "neda")
......@@ -425,7 +428,7 @@ void TreeBuilder::AddDetector(TString Name, TString ADFKey, Int_t MandatoryMode)
fListOfDets.push_back(det);
}
else {
Log << error << Name << " ==> Unkonwn detector " << dolog;
Log << error << Name << " ; " << ADFKey << " ==> Unkonwn detector of trigger" << dolog;
return;
}
}
......
......@@ -301,6 +301,7 @@ void initialize()
LUT[0xFA010305] = "algo:tracked";
LUT[0xCA000100] = "event:data";
LUT[0xCA010101] = "event:data:crystal";
LUT[0xCA010104] = "event:data:ccrystal";
LUT[0xCA010102] = "event:data:psa";
LUT[0xCA010103] = "event:data:tracked";
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment