Condition in "Draw" and "CopyTree" works differently

Dear rooters,

we found that if we use the Draw function with a condition (CUTG or numerical) it seems to work properly. But if we copy the original ttree using CopyTree function with the same condition and then use Draw with the new ttree (without condition) it looks like the condition has been applied partially.

Maybe, the tricky point is that the condition is applied to a vector of the branch.

struct ImpData{
public:
    ImpData();
    ~ImpData();
    uint64_t TIME; 	 // Calibrated time
    uint64_t TFAST;
    double EN; 	 // 
    double EX;
    double EY;
    double X,Y,Z;
    uint32_t NX,NY,NZ;
    double ZET;
    double AOQ;
    uint8_t ID; 	 
    uint32_t    CYCLE;
};

struct VetoData{
  public:
    VetoData();
    ~AncData();
    uint64_t TIME; 	 // Calibrated time
    double EN; 	 // Energy
    uint16_t ID;
    uint16_t INDEX1;
    uint16_t INDEX2;
    uint32_t     CYCLE;
    //** other stuff pending to define **//
    //** other stuff pending to define **//
};


struct betaData2TTree{
  public:
    betaData2TTree();
    ~betaData2TTree();
    uint64_t T; 	  // Calibrated time
    uint64_t TFast; 	
    double E; 	 // Energy
    double Ex; 	 // Energy
    double Ey; 	 // Energy
    uint32_t    Cycle;
    uint32_t nx,ny,nz;
    std::vector <ImpData>	vectorOfImp;
    std::vector <VetoData>	vectorOfVeto;
    int Clear();
};

The definitions of the constructors, destructors, and other functions are defined in other file (.cxx).

We have a TTree with several branches. The problematic one is filled with the structure betaData2TTree. So, if we type the following commands,

The definitions of the constructors, destructors, and other functions are defined in other file (.cxx).

We have a TTree with several branches. The problematic one is filled with the structure betaData2TTree. So, if we type the following commands,

[ul]
[0] .L myStructure.cxx++
[1] TFile * f = TFile::Open(“aFile.root”,“UPDATE”)
[2] TTree * oldTree = (TTree*)_file0->Get(“aTree”)
[3] oldTree->Draw(“beta.T-beta.vectorOfVeto.TIME”, “beta.T < beta.vectorOfVeto.TIME”) // This works ok
[4] newTTree = oldTree->CopyTree( “beta.T < beta.vectorOfVeto.TIME” )
[5] newTTree->Draw(“beta.T-beta.vectorOfVeto.TIME”) // This does not work
[/ul]

We would be glad if someone gives an idea.

Thank you for your time.

Regards,
Alvaro.

Hi Alvaro,

Intentionally, CopyTree copies in their entirely each for entry for which there is a least an element that match the criteria. So indeed, the ‘right’ Draw command afterward is (still): newTree->Draw("beta.T-beta.vectorOfVeto.TIME", "beta.T < beta.vectorOfVeto.TIME")

The reason is that doing anything else is ambiguous. If it is likely that you do not want copied over the element of the collection vectorOfVeto that do not match the criteria, the question arise on what to do about the other collections, should they be stripped the same way or should they be kept in full? Unfortunately the answer is likely to differ from data model to data model. [Besides, actually implementing the inner event stripping itself is a bit challenging code-wise].

Cheers,
Philippe.