Error while editing a software


I am editing a software that reads the binary data and makes a root file with certain information.

There are mainly 3 configuration files in which the details of each detector is there. It is working fine but there are details of many unused detectors and I want to remove those unused detectors But when I started removing those detectors then I am facing a strange problem.

Problem: Initially there was 24 detectors but I am able to remove 8 detectors. So, till When there are 16 detectors included in config file then its fine. But when I removed one more detector then initially it prints correct values from configuration file but after certain lines of code when I again print its value it is showing 0 instead of original value.

The Block of code before it prints correct value and after wrong value is (line no 262 in rd51_EventBuilderVFAT.C (87.5 KB)) is :

cout<<"############# Before initialization of Possible hitts \t(*DET[i]).PossibleHits = "<<(*DET[0]).PossibleHits<<endl;

    //--- Inizializing the detectors
    VFAT2* VFAT[MaxNumbersOfDetDir];
    for (Int_t i=0; i<chips_per_evt; i++)
        VFAT[i] = new VFAT2(0XFFFF,128,0,"","",0,0,0,0);
//cout<<"VFAT["<<i<<"] = "<<VFAT[i]<<endl;
cout<<"############# Before initialization of Possible hitts \t(*DET[i]).PossibleHits = "<<(*DET[0]).PossibleHits<<endl;

Here first cout prints correct value and next prints wrong value.

Where the class VFAT2 is defined like


//Explicit Constructors

VFAT2::VFAT2( unsigned short ChId,
int Chs,
int DetId,
TString DetName,
TString DetSec,
bool ChInv,
int ChOff,
int TId,
int SId)
: TObject(),
ChipId( ChId ),
Channels( Chs ),
DetectorId( DetId ),
DetectorName( DetName ),
DetectorSector( DetSec ),
ChipInvert( ChInv ),
ChipOffset( ChOff ),
TurboId( TId ),
SlotId( SId )
{} [/code]

Please suggest what may be happening wrong and how can I fix it?

Also I attached full code if you need to have a look.

Thanks in advance for your help.


One possible way of debugging your code would be to use ACLiC (it is difficult to guess what could be wrong with the code you posted)

Cheers, Bertrand.

Dear Bertrand,

Thanks for your reply. But I figured out the problem. There was problem with setting the size of array. And now it working.

You’re welcome, and glad to see you fixed the problem!

Cheers, Bertrand