fTriggerScalersDeltaEvent(),
fTriggerScalersDeltaRun(),
fTriggerInputsNames(kNTriggerInputs),
- fCTPConfig(NULL)
+ fCTPConfig(NULL),
+ fIRBufferArray(),
+ fIRInt2InteractionsMap(0),
+ fIRInt1InteractionsMap(0)
{
// default constructor
// destructor
for(Int_t i=0;i<kNMaxIR;i++)if(fIRArray[i])delete fIRArray[i];
delete fCTPConfig;
+
+ fIRBufferArray.Delete();
}
fTriggerScalersDeltaEvent(header.fTriggerScalersDeltaEvent),
fTriggerScalersDeltaRun(header.fTriggerScalersDeltaRun),
fTriggerInputsNames(TObjArray(kNTriggerInputs)),
- fCTPConfig(header.fCTPConfig)
+ fCTPConfig(header.fCTPConfig),
+ fIRBufferArray(),
+ fIRInt2InteractionsMap(header.fIRInt2InteractionsMap),
+ fIRInt1InteractionsMap(header.fIRInt1InteractionsMap)
{
// copy constructor
- SetName(header.fName);
- SetTitle(header.fTitle);
for(Int_t i = 0; i<kNMaxIR ; i++) {
if(header.fIRArray[i])fIRArray[i] = new AliTriggerIR(*header.fIRArray[i]);
else fIRArray[i]=0;
TNamed *str = (TNamed *)((header.fTriggerInputsNames).At(i));
if (str) fTriggerInputsNames.AddAt(new TNamed(*str),i);
}
+
+ for(Int_t i = 0; i < (header.fIRBufferArray).GetEntries(); ++i) {
+ AliTriggerIR *ir = (AliTriggerIR*)((header.fIRBufferArray).At(i));
+ if (ir) fIRBufferArray.Add(new AliTriggerIR(*ir));
+ }
}
AliESDHeader& AliESDHeader::operator=(const AliESDHeader &header)
fTriggerScalers = header.fTriggerScalers;
fTriggerScalersDeltaEvent = header.fTriggerScalersDeltaEvent;
fTriggerScalersDeltaRun = header.fTriggerScalersDeltaRun;
+ fIRInt2InteractionsMap = header.fIRInt2InteractionsMap;
+ fIRInt1InteractionsMap = header.fIRInt1InteractionsMap;
+
+ delete fCTPConfig;
fCTPConfig = header.fCTPConfig;
fTriggerInputsNames.Clear();
if (str) fTriggerInputsNames.AddAt(new TNamed(*str),i);
}
for(Int_t i = 0; i<kNMaxIR ; i++) {
+ delete fIRArray[i];
if(header.fIRArray[i])fIRArray[i] = new AliTriggerIR(*header.fIRArray[i]);
else fIRArray[i]=0;
}
- SetName(header.fName);
- SetTitle(header.fTitle);
+
+ fIRBufferArray.Delete();
+ for(Int_t i = 0; i < (header.fIRBufferArray).GetEntries(); ++i) {
+ AliTriggerIR *ir = (AliTriggerIR*)((header.fIRBufferArray).At(i));
+ if (ir) fIRBufferArray.Add(new AliTriggerIR(*ir));
+ }
}
return *this;
}
fTriggerScalersDeltaEvent.Reset();
fTriggerScalersDeltaRun.Reset();
fTriggerInputsNames.Clear();
+
+ fIRInt2InteractionsMap.ResetAllBits();
+ fIRInt1InteractionsMap.ResetAllBits();
+
delete fCTPConfig;
fCTPConfig = 0;
for(Int_t i=0;i<kNMaxIR;i++)if(fIRArray[i]){
delete fIRArray[i];
fIRArray[i]=0;
}
+
+ fIRBufferArray.Delete();
}
//______________________________________________________________________________
Bool_t AliESDHeader::AddTriggerIR(const AliTriggerIR* ir)
{
- // Adds trigger interaction record to array
- for(Int_t i=0;i<kNMaxIR;i++){
- if(!fIRArray[i]){
- fIRArray[i]=new AliTriggerIR(*ir);
- return 0;
- }
- }
- //AliErrorClass("Attempt to add # of IRs > kNMaxIR \n");
- return 1;
+ // Add an IR object into the array
+ // of IRs in the ESD header
+
+ fIRBufferArray.Add(new AliTriggerIR(*ir));
+
+ return kTRUE;
}
//______________________________________________________________________________
void AliESDHeader::Print(const Option_t *) const
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;i<nIR;i++){//1
+ IR=GetTriggerIR(i);
+ //
+ UInt_t orbit2 = IR->GetOrbit();
+ 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;j<nw;j++){//2
+ if(bint1[j]) flag1=1; // at least one int1 set
+ if(bint2[j]) flag2=1; // at least one int2 set
+ //printf("IR %d, bint1 %d, bint2 %d\n",i,bint1[j],bint2[j]);
+ }//2
+ // checking combinations
+ //
+
+ if((flag1*int1*flag2*int2)==1){// int1=1 & int2=1
+ nofIR++;
+ continue;
+ }
+ if(int1 == -1){// ignore int1
+ if(flag2&int2){// int2=1
+ nofIR++;
+ continue;
+ }
+ else if (!flag2&!int2){ //int2=0
+ nofIR++;
+ continue;
+ }
+ }
+
+ if(int2 ==-1){//ignore int2
+ if(flag1&int1){//int1=1
+ nofIR++;
+ continue;
+ }
+ else if(!flag1&!int1){ //int1=0
+ nofIR++;
+ continue;
+ }
+ }
+
+ if((flag1*int1)&!flag2&!int2){// int1=1, int2=0
+ nofIR++;
+ continue;
+ }
+
+ if((int2*flag2)&!int1&!flag1){// int1=0, int2=1
+ nofIR++;
+ continue;
+ }
+
+
+
+ }//1
+
+ return nofIR;
+}
+//__________________________________________________________________________
+TObjArray AliESDHeader::GetIRArray(Int_t int1, Int_t int2, Float_t deltaTime) const
+{
+ //
+ // returns an array of IR-s within time window deltaTime
+ // all possible combinations of int1 and int2 int1 - zdc bit, int2 v0 bit
+ //
+ const AliTriggerIR *IR;
+ TObjArray arr;
+ // 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)
+ //
+ // loop over IR-s
+ for(Int_t i=0;i<nIR;i++){//1
+ IR=GetTriggerIR(i);
+ //
+ UInt_t orbit2 = IR->GetOrbit();
+ 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;j<nw;j++){//2
+ if(bint1[j]) flag1=1; // at least one int1 set
+ if(bint2[j]) flag2=1; // at least one int2 set
+ }//2
+ // checking combinations
+ //
+ if((flag1*int1*flag2*int2)==1){// int1=1 & int2=1
+ arr.Add((AliTriggerIR*)IR); //add this IR
+ continue;
+ }
+ if(int1 == -1){// ignore int1
+ if(flag2&int2){// int2=1
+ arr.Add((AliTriggerIR*)IR); //add this IR
+ continue;
+ }
+ else if (!flag2&!int2){ //int2=0
+ arr.Add((AliTriggerIR*)IR); //add this IR
+ continue;
+ }
+ }
+ if(int2 ==-1){//ignore int2
+ if(flag1&int1){//int1=1
+ arr.Add((AliTriggerIR*)IR); //add this IR
+ continue;
+ }
+ else if(!flag1&!int1){ //int1=0
+ arr.Add((AliTriggerIR*)IR); //add this IR
+ continue;
+ }
+ }
+ if ((flag1*int1)&!flag2&!int2){// int1=1, int2=0
+ arr.Add((AliTriggerIR*)IR); //add this IR
+ continue;
+ }
+ if ((int2*flag2)&!int1&!flag1){// int1=0, int2=1
+ arr.Add((AliTriggerIR*)IR); //add this IR
+ continue;
+ }
+
+ }//1
+
+ return arr;
+}
+
+//__________________________________________________________________________
+void AliESDHeader::SetIRInteractionMap()
+{
+ //
+ // Function to compute the map of interations
+ // within 0TVX (int2) or V0A&V0C (int1) and the Event Id
+ // Note, the zero value is excluded
+ //
+ const AliTriggerIR *ir[5] = {GetTriggerIR(0),GetTriggerIR(1),GetTriggerIR(2),GetTriggerIR(3),GetTriggerIR(4)};
+
+ Long64_t orb = (Long64_t)GetOrbitNumber();
+ Long64_t bc = (Long64_t)GetBunchCrossNumber();
+
+ Long64_t evId = orb*3564 + bc;
+
+ for(Int_t i = 0; i < 5; ++i) {
+ if (ir[i] == NULL || ir[i]->GetNWord() == 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)
+{
+ //
+ // 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()
+{
+ //
+ // 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)
+{
+ //
+ // 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()
+{
+ //
+ // 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;
+}