/************************************************************************** * 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. * **************************************************************************/ //------------------------------------------------------------------------- // Implementation of Class AliESDHeader // Header data // for the ESD // Origin: Christian Klein-Boesing, CERN, Christian.Klein-Boesing@cern.ch //------------------------------------------------------------------------- #include "AliESDHeader.h" #include "AliTriggerScalersESD.h" #include "AliTriggerScalersRecordESD.h" #include "AliTriggerIR.h" #include "AliTriggerConfiguration.h" #include "AliLog.h" ClassImp(AliESDHeader) //______________________________________________________________________________ AliESDHeader::AliESDHeader() : AliVHeader(), fTriggerMask(0), fOrbitNumber(0), fTimeStamp(0), fEventType(0), fEventSpecie(0), fPeriodNumber(0), fEventNumberInFile(0), fBunchCrossNumber(0), fTriggerCluster(0), fL0TriggerInputs(0), fL1TriggerInputs(0), fL2TriggerInputs(0), fTriggerScalers(), fTriggerScalersDeltaEvent(), fTriggerScalersDeltaRun(), fTriggerInputsNames(kNTriggerInputs), fCTPConfig(NULL), fIRBufferArray(), fIRInt2InteractionsMap(0), fIRInt1InteractionsMap(0) { // default constructor SetName("AliESDHeader"); for(Int_t i = 0; i(&obj); if(!robj)return; // not an AliESDHeader *robj = *this; } //______________________________________________________________________________ void AliESDHeader::Reset() { // reset all data members fTriggerMask = 0; fOrbitNumber = 0; fTimeStamp = 0; fEventType = 0; fEventSpecie = 0; fPeriodNumber = 0; fEventNumberInFile = 0; fBunchCrossNumber = 0; fTriggerCluster = 0; fL0TriggerInputs = 0; fL1TriggerInputs = 0; fL2TriggerInputs = 0; fTriggerScalers.Reset(); fTriggerScalersDeltaEvent.Reset(); fTriggerScalersDeltaRun.Reset(); fTriggerInputsNames.Clear(); fIRInt2InteractionsMap.ResetAllBits(); fIRInt1InteractionsMap.ResetAllBits(); delete fCTPConfig; fCTPConfig = 0; for(Int_t i=0;iGetName()); } printf("\n"); } //______________________________________________________________________________ void AliESDHeader::SetActiveTriggerInputs(const char*name, Int_t index) { // Fill the active trigger inputs names // into the corresponding fTriggerInputsNames (TObjArray of TNamed) if (index >= kNTriggerInputs || index < 0) { AliError(Form("Index (%d) is outside the allowed range (0,59)!",index)); return; } fTriggerInputsNames.AddAt(new TNamed(name,NULL),index); } //______________________________________________________________________________ const char* AliESDHeader::GetTriggerInputName(Int_t index, Int_t trglevel) const { // Get the trigger input name // at the specified position in the trigger mask and trigger level (0,1,2) TNamed *trginput = 0; if (trglevel == 0) trginput = (TNamed *)fTriggerInputsNames.At(index); if (trglevel == 1) trginput = (TNamed *)fTriggerInputsNames.At(index+24); if (trglevel == 2) trginput = (TNamed *)fTriggerInputsNames.At(index+48); if (trginput) return trginput->GetName(); else return ""; } //______________________________________________________________________________ TString AliESDHeader::GetActiveTriggerInputs() const { // Returns the list with the names of the active trigger inputs TString trginputs; for(Int_t i = 0; i < kNTriggerInputs; i++) { TNamed *str = (TNamed *)((fTriggerInputsNames).At(i)); if (str) { trginputs += " "; trginputs += str->GetName(); trginputs += " "; } } return trginputs; } //______________________________________________________________________________ TString AliESDHeader::GetFiredTriggerInputs() const { // Returns the list with the names of the fired trigger inputs TString trginputs; for(Int_t i = 0; i < kNTriggerInputs; i++) { TNamed *str = (TNamed *)((fTriggerInputsNames.At(i))); if (i < 24 && (fL0TriggerInputs & (1 << i))) { if (str) { trginputs += " "; trginputs += str->GetName(); trginputs += " "; } } if (i >= 24 && i < 48 && (fL1TriggerInputs & (1 << (i-24)))) { if (str) { trginputs += " "; trginputs += str->GetName(); trginputs += " "; } } if (i >= 48 && (fL2TriggerInputs & (1 << (i-48)))) { if (str) { trginputs += " "; trginputs += str->GetName(); trginputs += " "; } } } return trginputs; } //______________________________________________________________________________ Bool_t AliESDHeader::IsTriggerInputFired(const char *name) const { // Checks if the trigger input is fired TNamed *trginput = (TNamed *)fTriggerInputsNames.FindObject(name); if (!trginput) return kFALSE; Int_t inputIndex = fTriggerInputsNames.IndexOf(trginput); if (inputIndex < 0) return kFALSE; if (fL0TriggerInputs & (1 << inputIndex)) return kTRUE; else if (fL1TriggerInputs & (1 << (inputIndex-24))) return kTRUE; else if (fL2TriggerInputs & (1 << (inputIndex-48))) return kTRUE; else return kFALSE; } //________________________________________________________________________________ Int_t AliESDHeader::GetTriggerIREntries(Int_t int1, Int_t int2, Float_t deltaTime) const { // returns number of IR-s within time window deltaTime // all possible combinations of int1 and int2 int1 - zdc bit, int2 v0 bit // const AliTriggerIR *IR; // triggered event Int_t nIR = GetTriggerIREntries(); UInt_t orbit1 = GetOrbitNumber(); const Double_t ot=0.0889218; //orbit time msec Float_t timediff; // time difference between orbits (msec) // Int_t nofIR; nofIR=0; // loop over IR-s for(Int_t i=0;iGetOrbit(); timediff = (orbit2<=orbit1) ? (Float_t)((orbit1-orbit2))*ot : (Float_t)((16777215-orbit1+orbit2))*ot; if (timediff>deltaTime) continue; //timediff outside time window if((int1&int2) == -1){ //ignore both bits, just count IR-s within time window nofIR++; continue; } // now check if int1, int2 bits are set UInt_t nw = IR->GetNWord(); Bool_t *bint1 = IR->GetInt1s(); Bool_t *bint2 = IR->GetInt2s(); // Int_t flag1,flag2; flag1=0; flag2=0; for(UInt_t j=0;jGetOrbit(); timediff = (orbit2<=orbit1) ? (Float_t)((orbit1-orbit2))*ot : (Float_t)((16777215-orbit1+orbit2))*ot; if (timediff>deltaTime) continue; //timediff outside time window if((int1&int2) == -1){ //ignore both bits, just count IR-s within time window arr.Add((AliTriggerIR*)IR); //add this IR continue; } // now check if int1, int2 bits are set UInt_t nw = IR->GetNWord(); Bool_t *bint1 = IR->GetInt1s(); Bool_t *bint2 = IR->GetInt2s(); // Int_t flag1,flag2; flag1=0; flag2=0; for(UInt_t j=0;jGetNWord() == 0) continue; Long64_t irOrb = (Long64_t)ir[i]->GetOrbit(); Bool_t* int2 = ir[i]->GetInt2s(); Bool_t* int1 = ir[i]->GetInt1s(); UShort_t* bcs = ir[i]->GetBCs(); for(UInt_t nW = 0; nW < ir[i]->GetNWord(); ++nW) { Long64_t intId = irOrb*3564 + (Long64_t)bcs[nW]; if (int2[nW] == kTRUE) { Int_t item = (intId-evId); Int_t bin = FindIRIntInteractionsBXMap(item); if(bin>=0) { fIRInt2InteractionsMap.SetBitNumber(bin,kTRUE); } } if (int1[nW] == kTRUE) { Int_t item = (intId-evId); Int_t bin = FindIRIntInteractionsBXMap(item); if(bin>=0) { fIRInt1InteractionsMap.SetBitNumber(bin,kTRUE); } } } } fIRInt2InteractionsMap.Compact(); fIRInt1InteractionsMap.Compact(); } //__________________________________________________________________________ Int_t AliESDHeader::FindIRIntInteractionsBXMap(Int_t difference) const { // // The mapping is of 181 bits, from -90 to +90 // Int_t bin=-1; if(difference<-90 || difference>90) return bin; else { bin = 90 + difference; } return bin; } //__________________________________________________________________________ Int_t AliESDHeader::GetIRInt2ClosestInteractionMap() const { // // Calculation of the closest interaction // SetIRInteractionMap(); Int_t firstNegative=100; for(Int_t item=-1; item>=-90; item--) { Int_t bin = FindIRIntInteractionsBXMap(item); Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin); if(isFired) { firstNegative = item; break; } } Int_t firstPositive=100; for(Int_t item=1; item<=90; item++) { Int_t bin = FindIRIntInteractionsBXMap(item); Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin); if(isFired) { firstPositive = item; break; } } Int_t closest = firstPositive < TMath::Abs(firstNegative) ? firstPositive : TMath::Abs(firstNegative); if(firstPositive==100 && firstNegative==100) closest=0; return closest; } //__________________________________________________________________________ Int_t AliESDHeader::GetIRInt1ClosestInteractionMap(Int_t gap) const { // // Calculation of the closest interaction // In case of VZERO (Int1) one has to introduce a gap // in order to avoid false positivies from after-pulses SetIRInteractionMap(); Int_t firstNegative=100; for(Int_t item=-1; item>=-90; item--) { Int_t bin = FindIRIntInteractionsBXMap(item); Bool_t isFired = fIRInt1InteractionsMap.TestBitNumber(bin); if(isFired) { firstNegative = item; break; } } Int_t firstPositive=100; for(Int_t item=1+gap; item<=90; item++) { Int_t bin = FindIRIntInteractionsBXMap(item); Bool_t isFired = fIRInt1InteractionsMap.TestBitNumber(bin); if(isFired) { firstPositive = item; break; } } Int_t closest = firstPositive < TMath::Abs(firstNegative) ? firstPositive : TMath::Abs(firstNegative); if(firstPositive==100 && firstNegative==100) closest=0; return closest; } //__________________________________________________________________________ Int_t AliESDHeader::GetIRInt2LastInteractionMap() const { // // Calculation of the last interaction // SetIRInteractionMap(); Int_t lastNegative=0; for(Int_t item=-90; item<=-1; item++) { Int_t bin = FindIRIntInteractionsBXMap(item); Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin); if(isFired) { lastNegative = item; break; } } Int_t lastPositive=0; for(Int_t item=90; item>=1; item--) { Int_t bin = FindIRIntInteractionsBXMap(item); Bool_t isFired = fIRInt2InteractionsMap.TestBitNumber(bin); if(isFired) { lastPositive = item; break; } } Int_t last = lastPositive > TMath::Abs(lastNegative) ? lastPositive : TMath::Abs(lastNegative); return last; }